Skip to content

Releases: apple/swift-argument-parser

ArgumentParser 0.5.0

03 Sep 17:32
6b2aa27
Compare
Choose a tag to compare

Additions

  • When a user doesn't provide a required argument, the error message now includes that argument's help text. (#324)
  • Command-line tools built with ArgumentParser now include an experimental flag to dump command/argument/help information as JSON: --experimental-dump-help. (#310)

Changes

  • All public enumerations are now structs with static properties, to make compatibility with future additions simpler.

Fixes

  • Array properties defined as @Option with the .upToNextOption parsing strategy now include all provided values. (#304) In the example below, all four values are now included in the resulting array, where only the last two were included in previous releases:

    struct Example: ParsableCommand {
        @Option(parsing: .upToNextOption)
        var option: String
    }
    $ example --option one two --option three four
    
  • When a command defines an array property as an @Argument with the .unconditionalRemaining parsing strategy, option and flag parsing now stops at the first positional argument or unrecognized flag. (#333)

  • Completion scripts correctly use customized help flags. (#308)

  • Fixes errors with bash custom completion arguments and the executable path. (#320, #323)

  • Fixes the behavior when a user specifies both the help subcommand and a help flag. (#309)

  • A variety of internal improvements. (#315, #316, #321, #341)

ArgumentParser 0.4.4

30 Jul 17:19
Compare
Choose a tag to compare

Fixes

  • Includes a workaround for a runtime crash with certain OptionGroup configurations when a command is compiled in release mode.

ArgumentParser 0.4.3

28 Apr 15:42
986d191
Compare
Choose a tag to compare

Additions

  • Experimental API for hiding @OptionGroup-declared properties from the help screen.

ArgumentParser 0.4.2

21 Apr 23:01
47bd06e
Compare
Choose a tag to compare

Fixes

  • Both parts of a flag with an inversion are now hidden when specified.
  • Better support for building on OpenBSD.
  • Optional unparsed values are now always properly decoded. (#290)
  • Help information from super-commands is no longer unnecessarily injected into subcommand help screens.

ArgumentParser 0.4.1

08 Mar 21:01
831ed5e
Compare
Choose a tag to compare

Additions

  • When a user provides an invalid value as an argument or option, the error message now includes the help text for that argument.

Fixes

  • Zsh completion scripts for commands that include a hyphen no longer cause errors.
  • Optional unparsed values are now decoded correctly in ParsableArguments types.

ArgumentParser 0.4.0

04 Mar 21:52
69ddee8
Compare
Choose a tag to compare

Additions

  • Short options can now support "joined option" syntax, which lets users specify a value appended immediately after the option's short name. For example, in addition to calling this example command with -D debug and -D=debug, users can now write -Ddebug for the same parsed value. (#240)

    @main
    struct Example: ParsableCommand {
        @Option(name: .customShort("D", allowingJoined: true))
        var debugValue: String
      
        func run() {
            print(debugValue)
        }
    }

Changes

  • The CommandConfiguration.helpNames property is now optional, to allow the overridden help flags of parent commands to flow down to their children. Most existing code should not be affected, but if you've customized a command's help flags you may see different behavior. (#251)

  • The errorCode property is no longer used as a command's exit code when CustomNSError types are thrown. (#276)

    Migration: Instead of throwing a CustomNSError type, print your error manually and throw an ExitCode error to customize your command's exit code.

Removals

  • Old, deprecated property wrapper initializers have been removed.

Fixes

  • Validation errors now show the correct help flags when help flags have been customized.
  • Options, flags, and arguments that are marked as hidden from the help screen are also suppressed from completion scripts.
  • Non-parsed variable properties are now allowed in parsable types.
  • Error messages produced when NSError types are thrown have been improved.
  • The usage line for commands with a large number of options includes more detail about required flags and positional arguments.
  • Support for CMake builds on Apple Silicon is improved.

ArgumentParser 0.3.2

16 Jan 05:47
9564d61
Compare
Choose a tag to compare

Fixes

  • Changes made to a command's properties in its validate method are now persisted.
  • The exit code defined by error types that conform to CustomNSError are now honored.
  • Improved error message when declaring a command type with an unadorned mutable property. (See #256 for more.)
  • Migrated from CRT to MSVCRT for Windows platforms.
  • Fixes and improvements for building with CMake for Windows and Apple Silicon.
  • Documentation improvements.

ArgumentParser 0.3.1

02 Sep 15:42
92646c0
Compare
Choose a tag to compare

Fixes

  • An option or flag can now declare a name with both single- and double-
    dash prefixes, such as -my-flag and --my-flag. Specify both names in the
    name parameter when declaring your property:

    @Flag(name: [.long, .customLong("my-flag", withSingleDash: true)])
    var myFlag = false
  • Parsing performance improvements.

ArgumentParser 0.3.0

15 Aug 18:16
15351c1
Compare
Choose a tag to compare

Additions

  • Shell completions scripts are now available for Fish.

Changes

  • Array properties without a default value are now treated as required for the
    user of a command-line tool. In previous versions of the library, these
    properties defaulted to an empty array; a deprecation was introduced for this
    behavior in version 0.2.0.

    Migration: Specify an empty array as the default value for properties that
    should not require user input:

    // old
    @Option var names: [String]
    // new
    @Option var names: [String] = []

ArgumentParser 0.2.2

05 Aug 17:52
3e7d2fe
Compare
Choose a tag to compare

Fixes

  • Zsh completion scripts have improved documentation and better support
    multi-word completion strings, escaped characters, non-standard executable
    locations, and empty help strings.