Commit Graph

10 Commits

Author SHA1 Message Date
Kth 18b0039973 Fix Repeat's endless printing (#437)
Co-authored-by: Nate Cook <natecook@apple.com>
2022-04-02 15:13:09 -05:00
Nate Cook 1141ed1e1b Support an async entry point for commands (#404)
Adds a new `AsyncParsableCommand` protocol, which provides a
`static func main() async` entry point and can call through to the root
command's or a subcommand's asynchronous `run()` method. For this
asynchronous execution, the root command must conform to `AsyncParsableCommand`,
but its subcommands can be a mix of asynchronous and synchronous commands.

Due to an issue in Swift 5.5, you can only use `@main` on an
`AsyncParsableCommand` root command starting in Swift 5.6.
This change also includes a workaround for clients that are using Swift 5.5.
Declare a separate type that conforms to `AsyncMainProtocol` and add the `@main`
attribute to that type.

```
@main enum Main: AsyncMain {
    typealias Command = <#command#>
}
```
2022-03-14 18:14:09 -05:00
Jake Petroules b2e411887e Fix compile failure on iOS for Mac Catalyst support (#372) 2021-11-08 19:50:43 -06:00
Gonzalo RH 530a754555 Included help message when a required value is missing. (#324) 2021-06-09 11:28:00 -05:00
Alfredo Delli Bovi 4793b0f4b9 Include help text in error message when validation fails (#283) 2021-03-06 13:11:58 -06:00
Nate Cook 85196ee1d8 Additional help messages (#165)
* Add 'see help' messages to usage messages and the help screen

* Update tests for new help messages.

* Update guide examples with additional help messages
2020-05-22 17:04:14 -05:00
John Mueller 501bf60536 Display help when no arguments results in error (#140)
If a command cannot successfully run with zero arguments, print the error and the full help message instead of the short usage message.

This closes #134.
2020-05-14 09:08:19 -05:00
Nate Cook 31799bc1b4 Add built-in support for --version flag (#102)
* Add built-in support for --version flag

* Test that command-defined --version overrides the built-in.

* Document the `version:` parameter in CommandConfiguration

* Include --version in the generated help.
2020-03-30 12:36:21 -05:00
Nate Cook ddc828f8cb Add an API for converting an error to an exit code (#79)
* Add an API for converting an error to an exit code

* Make ExitCode more useful as a value type

* Update tests to use ExitCode values

* Typo fix

* Add a test for ExitCode.isSuccess

* Switch to just using ExitCode for tests
2020-03-21 12:44:32 -05:00
Elliott Williams 34300696f5 Prefix test target names with "ArgumentParser" (#74)
* Prefix testing and test helper targets with ArgumentParser

* Replace SAP with ArgumentParser in imports and CMakeLists
2020-03-10 12:44:07 -05:00