Swift: Announcing ArgumentParser
swift.org
Swift: Announcing ArgumentParser
1–10 of 27 posts
Re: Swift: Announcing ArgumentParser
#2Very few libraries creates its API so well as to transcend its origins (JodaTime comes to mind).
* Node.js [2]
* Java/JVM [3]
* Go [4]
* Lua [5]
* C++ [6] [7]
It appears there is no Swift port.
That is unfortunate, because besides the basics (optionals, positions, defaults, short and log options, auto generated docs, subcommands, descriptions, repeating options), it lets you do argument groups, mutually exclusive options, customizable help behavior, variable customization, custom parsers/validators, options with multiple arguments. There's even Python support for shell autocomplete library. [7].
(One potential limitation is that it is naturally dynamic, and not typesafe like Swift's new ArgumentParser. IMO that is of relatively small practical importance compared to its other features.)
It's both simple enough to get going, but sophisticated enough that I've never wanted for anything. It's the first thing I look for when writing a CLI.
[1] https://docs.python.org/3/library/argparse.html
[2] http://nodeca.github.io/argparse/
[3] https://argparse4j.github.io/
[4] https://github.com/akamensky/argparse
[5] https://github.com/mpeterv/argparse
[6] https://github.com/jbms/argparse
Re: Swift: Announcing ArgumentParser
#3One of my very, very, very favorite things about Python is argparse. [1] Very few libraries creates its API so well as to transcend its origins (JodaTime comes to mind). * Node.js [2] * Java/JVM [3] * Go [4] * Lua [5] * C++ [6] [7] It appears there is no Swift port. That is unfortunate, because besides the basics (optionals, positions, defaults, short and log options, auto generated docs, subcommands, descriptions, r…
At least in the argument parsing space, docopt[0] did as well, with official implementations in ~22 languages. It might not always be the best native approach, but the one I will reach for when I have to do argument parsing in a new language.
Re: Swift: Announcing ArgumentParser
#4One of my very, very, very favorite things about Python is argparse. [1] Very few libraries creates its API so well as to transcend its origins (JodaTime comes to mind). * Node.js [2] * Java/JVM [3] * Go [4] * Lua [5] * C++ [6] [7] It appears there is no Swift port. That is unfortunate, because besides the basics (optionals, positions, defaults, short and log options, auto generated docs, subcommands, descriptions, r…
> Very few libraries creates its API so well as to transcend its origins At least in the argument parsing space, docopt[0] did as well, with official implementations in ~22 languages. It might not always be the best native approach, but the one I will reach for when I have to do argument parsing in a new language.
I've used it in Ruby, for which IMO it is the best available choice.
But there is only so much you can express in docopt, and I quickly begin missing the flexibility of a "real" API and argparse.
Re: Swift: Announcing ArgumentParser
#5If this is an improvement, why are you telling me instead of showing me?
Personally, the problem is command line tools, not argument parsing. Why would anyone create a command line tool instead of a GUI that only lets you enter the correct set of arguments that go together, grouped into a coherent UI?
The end result should be a json. We all know how to parse json in Swift and every other language in existence.
Re: Swift: Announcing ArgumentParser
#6Can we please have a 'New Version', 'Old Version' comparison, side by side. If this is an improvement, why are you telling me instead of showing me? Personally, the problem is command line tools, not argument parsing. Why would anyone create a command line tool instead of a GUI that only lets you enter the correct set of arguments that go together, grouped into a coherent UI? The end result should be a json. We all k…
And why should everything be JSON? It's not the best format ever for all the things (there isn't one).
Re: Swift: Announcing ArgumentParser
#7That is an awful default error for validating the type. The program knows it failed to parse as an Int but doesn't tell you anything about that.
Error: The value 'ZZZ' is invalid for '' of type Int
Also, the help should automatically tell you the expected types as well.
ARGUMENTS: : Int The highest value to pick.
Re: Swift: Announcing ArgumentParser
#8Can we please have a 'New Version', 'Old Version' comparison, side by side. If this is an improvement, why are you telling me instead of showing me? Personally, the problem is command line tools, not argument parsing. Why would anyone create a command line tool instead of a GUI that only lets you enter the correct set of arguments that go together, grouped into a coherent UI? The end result should be a json. We all k…
Re: Swift: Announcing ArgumentParser
#9Error: The value 'ZZZ' is invalid for ' ' That is an awful default error for validating the type. The program knows it failed to parse as an Int but doesn't tell you anything about that. Error: The value 'ZZZ' is invalid for ' ' of type Int Also, the help should automatically tell you the expected types as well. ARGUMENTS: : Int The highest value to pick.
Re: Swift: Announcing ArgumentParser
#10One of my very, very, very favorite things about Python is argparse. [1] Very few libraries creates its API so well as to transcend its origins (JodaTime comes to mind). * Node.js [2] * Java/JVM [3] * Go [4] * Lua [5] * C++ [6] [7] It appears there is no Swift port. That is unfortunate, because besides the basics (optionals, positions, defaults, short and log options, auto generated docs, subcommands, descriptions, r…