Swift Argument Parser v0.4.0 Release Notes

Release Date: 2021-03-04 // about 3 years ago
  • โž• 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.

    ๐Ÿš€ The 0.4.0 release includes contributions from [CodaFi], [lorentey], [natecook1000], [schlagelk], and [Zoha131]. Thank you!