<div dir="ltr">I think it would be great to have something like this (at least the &quot;Arguments&quot; component) as part of the standard distribution — maybe as a corelib rather than as part of the standard library. Seeing as this is certainly not in scope for phase 1 of Swift 4, maybe it would be better to start this as an external library with the aim of having it brought into corelibs at some point in the future?<br><br>Also probably worth taking a look at existing libraries like &lt;<a href="https://github.com/jatoben/CommandLine">https://github.com/jatoben/CommandLine</a>&gt;, &lt;<a href="https://github.com/nomothetis/OptionKit">https://github.com/nomothetis/OptionKit</a>&gt;, and &lt;<a href="https://github.com/marcoconti83/targone">https://github.com/marcoconti83/targone</a>&gt; to see what other people have tried.<div><br></div><div>Will<br><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 17, 2016 at 4:20 AM Russ Bishop via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I want to pitch a command line parsing addition to the standard library and get feedback before I polish up a full proposal.<br>
<br>
Swift is being positioned to fill numerous functions, including as a local scripting language. I think that’s great but having tried to use it for that purpose there are a number of holes that need to be filled. Parsing command arguments (and printing help / doing shell autocompletion) is enough of a common task that I think it deserves to be part of the standard library… not to mention the huge PITA that it becomes to attempt to use a third-party library from a shell script.<br>
<br>
I’m especially interested in Dimitri or Robert’s opinions on whether this kind of thing meets the standard library bar.<br>
<br>
<br>
I’m looking toward some protocols that describe commands and their options, including short and long form (-/--), --opt=value, etc. Type-safe using enums that can convert from raw values, automatic printing of error &amp; usage info when invalid options are passed. I’d also like to support loading localized descriptions for the help text from a bundle for i8n support (subject to what support exists in Swift’s Foundation).<br>
<br>
<br>
If we can fill some of these holes it would make using swift scripts and command line utilities a much nicer experience.<br>
<br>
<br>
Russ<br>
<br>
<br>
<br>
Eventually I’d like to build up several components:<br>
<br>
* Arguments - parse command line args, print command help, support shell auto-complete<br>
* Terminal - Psuedo-terminal support, line discipline control, ANSI colors &amp; other escape codes/commands, progress bars and other nice things for output<br>
* TerminalEditor - a swift interface to ncurses, term box, or some similar cross-platform lib for doing command-line editing<br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>