Releases: apple/swift-argument-parser
ArgumentParser 0.4.2
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
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
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 whenCustomNSError
types are thrown. (#276)Migration: Instead of throwing a
CustomNSError
type, print your error manually and throw anExitCode
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
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
toMSVCRT
for Windows platforms. - Fixes and improvements for building with CMake for Windows and Apple Silicon.
- Documentation improvements.
ArgumentParser 0.3.1
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
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
Fixes
- Zsh completion scripts have improved documentation and better support
multi-word completion strings, escaped characters, non-standard executable
locations, and empty help strings.
ArgumentParser 0.2.1
Additions
- You can now generate Bash and Zsh shell completion scripts for commands,
either by using the--generate-completion-script
flag when running a
command, or by calling the staticcompletionScript(for:)
method on a root
ParsableCommand
type. See the guide to completion scripts for
information on customizing and installing the completion script for your
command.
Fixes
- Property wrappers without parameters can now be written without parentheses
— e.g.@Flag var verbose = false
. - When displaying default values for array properties, the help screen now
correctly uses the element type'sExpressibleByArgument
conformance to
generate the description. - Running a project that defines a command as its own subcommand now fails with
a useful error message.
ArgumentParser 0.2.0
Additions
- You can now specify default values for array properties of parsable types.
The default values are overridden if the user provides at least one value
as part of the command-line arguments.
Changes
-
This release of
swift-argument-parser
requires Swift 5.2. -
Default values for all properties are now written using default initialization
syntax, including some values that were previously implicit, such as empty
arrays andfalse
for Boolean flags.Migration: Specify default values using typical Swift default value syntax
to remove the deprecation warnings:// old @Flag() var verbose: Bool // new @Flag() var verbose = false
Important: There is a semantic change for flags with inversions that do
not have a default value. In previous releases, these flags had a default
value offalse
; starting in 0.2.0, these flags will have no default, and
will therefore be required by the user. Specify a default value offalse
to
retain the old behavior.
Fixes
- Options with multiple names now consistently show the first-declared name
in usage and help screens. - Default subcommands are indicated in the help screen.
- User errors with options are now shown before positional argument errors,
eliminating some false negative reports. - CMake compatibility fixes.
ArgumentParser 0.1.0
Additions
- Error messages and help screens now include information about how to request
more help. - CMake builds now support installation.
Changes
-
The
static func main()
method onParsableCommand
no longer returns
Never
. This allowsParsableCommand
types to be designated as the entry
point for a Swift executable by using the@main
attribute.Migration: For most uses, this change is source compatible. If you have
usedmain()
where a() -> Never
function is explicitly required, you'll
need to change your usage or capture the method in another function. -
Optional
no longer conforms toExpressibleByArgument
, to avoid some
property declarations that don't make sense.Migration: This is source-compatible for all property declarations, with
deprecations for optional properties that define an explicit default. If
you're using optional values where anExpressibleByArgument
type is
expected, such as a generic function, you will need to change your usage
or provide an explicit override. -
ParsableCommand
'srun()
method requirement is now amutating
method,
allowing mutations to a command's properties, such as sorting an array of
arguments, without additional copying.Migration: No changes are required for commands that are executed through
themain()
method. If you manually parse a command and then call its
run()
method, you may need to change the command from a constant to a
variable.
Removals
- The
@Flag
initializers that were deprecated in version 0.0.6 are now
marked as unavailable.
Fixes
@Option
properties of an optional type that use atransform
closure now
correctly indicate their optionality in the usage string.- Correct wrapping and indentation are maintained for abstracts and discussions
with short lines. - Empty abstracts no longer add extra blank lines to the help screen.
- Help requests are still honored even when a parsed command fails validation.
- The
--
terminator isn't consumed when parsing a command, so that it can be
parsed as a value when a subcommand includes an.unconditionalRemaining
argument array. - CMake builds work correctly again.