[swift-evolution] [Pitch][stdlib] Command Line Option Parsing & Help

Will Field-Thompson will.a.ft at gmail.com
Wed Aug 17 11:41:51 CDT 2016


I think it would be great to have something like this (at least the
"Arguments" 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?

Also probably worth taking a look at existing libraries like <
https://github.com/jatoben/CommandLine>, <
https://github.com/nomothetis/OptionKit>, and <
https://github.com/marcoconti83/targone> to see what other people have
tried.

Will


On Wed, Aug 17, 2016 at 4:20 AM Russ Bishop via swift-evolution <
swift-evolution at swift.org> wrote:

> I want to pitch a command line parsing addition to the standard library
> and get feedback before I polish up a full proposal.
>
> 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.
>
> I’m especially interested in Dimitri or Robert’s opinions on whether this
> kind of thing meets the standard library bar.
>
>
> 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 &
> 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).
>
>
> If we can fill some of these holes it would make using swift scripts and
> command line utilities a much nicer experience.
>
>
> Russ
>
>
>
> Eventually I’d like to build up several components:
>
> * Arguments - parse command line args, print command help, support shell
> auto-complete
> * Terminal - Psuedo-terminal support, line discipline control, ANSI colors
> & other escape codes/commands, progress bars and other nice things for
> output
> * TerminalEditor - a swift interface to ncurses, term box, or some similar
> cross-platform lib for doing command-line editing
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160817/4fdf5c03/attachment.html>


More information about the swift-evolution mailing list