clap/examples/16_app_settings.md
Ed Page bfa02fd418 test: More thoroughly test examples
This ports our example testing over to [trycmd](https://docs.rs/) so
we can:
- More thoroughly test our examples
- Provide always-up-to-date example usage

The old way of testing automatically picked up examples.  This new way
requires we have a `.md` file that uses the example in some way.

Notes:
- Moved overall example description to the `.md` file
- I added cross-linking between related examples
- `14_groups` had a redundant paragraph (twice talked about "one and
  only one"
2021-11-23 13:13:41 -06:00

1.1 KiB

You can use AppSettings to change the application level behavior of clap. app.setting() function takes AppSettings enum as argument. You can learn more about AppSettings in the documentation, which also has examples on each setting.

This example will only show usage of one AppSettings setting. See documentation for more information.

Something is required:

$ 16_app_settings
? failed
error: The following required arguments were not provided:
    <input>

USAGE:
    16_app_settings[EXE] <input>
    16_app_settings[EXE] <SUBCOMMAND>

For more information try --help

It can either be an argument:

$ 16_app_settings input.txt
The input file is: input.txt

Or the test subcommand:

$ 16_app_settings test
The 'test' subcommand was used

And see what this looks like in the help:

$ 16_app_settings --help
myapp 

USAGE:
    16_app_settings[EXE] <input>
    16_app_settings[EXE] <SUBCOMMAND>

ARGS:
    <input>    input file to use

OPTIONS:
    -h, --help    Print help information

SUBCOMMANDS:
    help    Print this message or the help of the given subcommand(s)
    test    does some testing