docs: update external command usage string instructions

This commit is contained in:
Rylan Polster 2021-01-18 12:09:16 -05:00
parent 6d3d88d33e
commit 4bf4d3e26e
No known key found for this signature in database
GPG Key ID: 46A744940CFF4D64

View File

@ -84,9 +84,7 @@ module Homebrew
def foo_args def foo_args
Homebrew::CLI::Parser.new do Homebrew::CLI::Parser.new do
usage_banner <<~EOS description <<~EOS
`foo` [<options>] <formula|cask>
Do something. Place a description here. Do something. Place a description here.
EOS EOS
switch "-f", "--force", switch "-f", "--force",
@ -113,7 +111,7 @@ Using the above will generate appropriate help text:
```console ```console
$ brew foo --help $ brew foo --help
Usage: brew foo [options] formula|cask Usage: brew foo [options] formula|cask [...]
Do something. Place a description here. Do something. Place a description here.
@ -127,6 +125,8 @@ Do something. Place a description here.
-h, --help Show this message. -h, --help Show this message.
``` ```
The usage string is automatically generated based on the specified number and type of named arguments (see below for more details on specifying named arguments). The generated usage string can be overridden by passing the correct usage string to the `usage_banner` method (placed just before the `description` method). See the [`brew tap` command](https://github.com/Homebrew/brew/blob/HEAD/Library/Homebrew/cmd/tap.rb) for an example.
Use the `named_args` method to specify the type and number of named arguments that are expected. Pass either a symbol to indicate the type of argument expected, an array of symbols to indicate that multiple types should be expected, or an array of strings to specify which specific options should be expected (see the [`brew analytics`](https://github.com/Homebrew/brew/blob/HEAD/Library/Homebrew/cmd/analytics.rb) command for an example of this). Use the `named_args` method to specify the type and number of named arguments that are expected. Pass either a symbol to indicate the type of argument expected, an array of symbols to indicate that multiple types should be expected, or an array of strings to specify which specific options should be expected (see the [`brew analytics`](https://github.com/Homebrew/brew/blob/HEAD/Library/Homebrew/cmd/analytics.rb) command for an example of this).
Pass an integer to the `number`, `min`, or `max` parameter of `named_args` to specify the number of named arguments that are expected. See the following examples: Pass an integer to the `number`, `min`, or `max` parameter of `named_args` to specify the number of named arguments that are expected. See the following examples: