Announcing ArgumentParser

We’re delighted to announce ArgumentParser, a new open-source library that makes it straightforward, even enjoyable!, to parse command-line arguments in Swift.

swift.org/blog/argument-parser/

The Swift ArgumentParser library simplifies parsing command-line arguments with a type-safe, declarative approach using Swift features like property wrappers and reflection. It supports building tools from simple scripts to complex utilities with subcommands, as shown in a random number generator example with number and pick subcommands.

The library auto-generates help and error messages, validates inputs, and reduces boilerplate, aiming to promote best practices and scalability. Designed to replace SwiftPM’s TSCUtility parser, it’s being adopted across Swift projects like indexstore-db and swift-format, with plans for SwiftPM and the compiler driver. Developers are encouraged to experiment, provide feedback, and help shape its 1.0 release for broader platform support.


Enjoyed this post?

Well, you could share the post with others, follow me with RSS Feeds, send me a comment via email, and/or leave a donation in the Tip Jar.


Tags

Category:

Tag:

Year: