Cleanup usage strings for flags

This commit is contained in:
Rylan Polster 2021-01-18 11:03:23 -05:00
parent 6f69aab6cf
commit a9a0c415e7
No known key found for this signature in database
GPG Key ID: 46A744940CFF4D64
3 changed files with 23 additions and 22 deletions

View File

@ -206,15 +206,15 @@ module Homebrew
end end
def flag(*names, description: nil, replacement: nil, required_for: nil, depends_on: nil) def flag(*names, description: nil, replacement: nil, required_for: nil, depends_on: nil)
required = if names.any? { |name| name.end_with? "=" } required, flag_type = if names.any? { |name| name.end_with? "=" }
OptionParser::REQUIRED_ARGUMENT [OptionParser::REQUIRED_ARGUMENT, :required_flag]
else else
OptionParser::OPTIONAL_ARGUMENT [OptionParser::OPTIONAL_ARGUMENT, :optional_flag]
end end
names.map! { |name| name.chomp "=" } names.map! { |name| name.chomp "=" }
description = option_to_description(*names) if description.nil? description = option_to_description(*names) if description.nil?
if replacement.nil? if replacement.nil?
process_option(*names, description, type: :flag) process_option(*names, description, type: flag_type)
else else
description += " (disabled#{"; replaced by #{replacement}" if replacement.present?})" description += " (disabled#{"; replaced by #{replacement}" if replacement.present?})"
end end
@ -462,10 +462,11 @@ module Homebrew
elsif @non_global_processed_options.count > 2 elsif @non_global_processed_options.count > 2
" [<options>]" " [<options>]"
else else
required_argument_types = [:required_flag, :comma_array]
@non_global_processed_options.map do |option, type| @non_global_processed_options.map do |option, type|
next " [<#{option}>]" if type == :switch next " [<#{option}>`=`]" if required_argument_types.include? type
" [<#{option}>`=`<#{option_to_name(option)}>]" " [<#{option}>]"
end.join end.join
end end

View File

@ -382,7 +382,7 @@ packages.
* `-f`, `--force`: * `-f`, `--force`:
Treat installed *`formula`* and provided *`formula`* as if they are from the same taps and migrate them anyway. Treat installed *`formula`* and provided *`formula`* as if they are from the same taps and migrate them anyway.
### `missing` [*`--hide`*`=`*`hide`*] [*`formula`* ...] ### `missing` [*`--hide`*`=`] [*`formula`* ...]
Check the given *`formula`* kegs for missing dependencies. If no *`formula`* are Check the given *`formula`* kegs for missing dependencies. If no *`formula`* are
provided, check all kegs. Will exit with a non-zero status if any kegs are found provided, check all kegs. Will exit with a non-zero status if any kegs are found
@ -550,7 +550,7 @@ using protocols other than HTTPS, e.g. SSH, git, HTTP, FTP(S), rsync.
* `--list-pinned`: * `--list-pinned`:
List all pinned taps. List all pinned taps.
### `tap-info` [*`--installed`*] [*`--json`*`=`*`json`*] [*`tap`* ...] ### `tap-info` [*`--installed`*] [*`--json`*] [*`tap`* ...]
Show detailed information about one or more *`tap`*s. Show detailed information about one or more *`tap`*s.
@ -711,7 +711,7 @@ that directory doesn't exist, `$(brew --repository)/Cellar`.
If *`formula`* is provided, display the location in the Cellar where *`formula`* If *`formula`* is provided, display the location in the Cellar where *`formula`*
would be installed, without any sort of versioned directory as the last path. would be installed, without any sort of versioned directory as the last path.
### `--env` [*`--shell`*`=`*`shell`*] [*`--plain`*] [*`formula`* ...] ### `--env` [*`--shell`*`=`] [*`--plain`*] [*`formula`* ...]
Summarise Homebrew's build environment as a plain list. Summarise Homebrew's build environment as a plain list.
@ -821,7 +821,7 @@ value, while `--no-rebuild` will remove it.
* `--root-url`: * `--root-url`:
Use the specified *`URL`* as the root of the bottle's URL instead of Homebrew's default. Use the specified *`URL`* as the root of the bottle's URL instead of Homebrew's default.
### `bump` [*`--limit`*`=`*`limit`*] [*`formula`* ...] ### `bump` [*`--limit`*`=`] [*`formula`* ...]
Display out-of-date brew formulae and the latest version available. Display out-of-date brew formulae and the latest version available.
Also displays whether a pull request has been opened with the URL. Also displays whether a pull request has been opened with the URL.
@ -915,7 +915,7 @@ nor vice versa. It must use whichever style specification the formula already us
* `-f`, `--force`: * `-f`, `--force`:
Ignore duplicate open PRs. Remove all mirrors if `--mirror` was not specified. Ignore duplicate open PRs. Remove all mirrors if `--mirror` was not specified.
### `bump-revision` [*`--dry-run`*] [*`--message`*`=`*`message`*] *`formula`* [...] ### `bump-revision` [*`--dry-run`*] [*`--message`*`=`] *`formula`* [...]
Create a commit to increment the revision of *`formula`*. If no revision is Create a commit to increment the revision of *`formula`*. If no revision is
present, "revision 1" will be added. present, "revision 1" will be added.
@ -1019,7 +1019,7 @@ or open the Homebrew repository for editing if no formula is provided.
* `--cask`: * `--cask`:
Treat all named arguments as casks. Treat all named arguments as casks.
### `extract` [*`--version`*`=`*`version`*] [*`--force`*] *`formula`* ... ### `extract` [*`--version`*`=`] [*`--force`*] *`formula`* ...
Look through repository history to find the most recent version of *`formula`* and Look through repository history to find the most recent version of *`formula`* and
create a copy in *`tap`*`/Formula/`*`formula`*`@`*`version`*`.rb`. If the tap is not create a copy in *`tap`*`/Formula/`*`formula`*`@`*`version`*`.rb`. If the tap is not
@ -1233,7 +1233,7 @@ Run a Ruby instance with Homebrew's libraries loaded, e.g.
* `-e`: * `-e`:
Execute the given text string as a script. Execute the given text string as a script.
### `sh` [*`--env`*`=`*`env`*] [*`--cmd`*`=`*`cmd`*] [*`file`*] ### `sh` [*`--env`*`=`] [*`--cmd`*`=`] [*`file`*]
Homebrew build environment that uses years-battle-hardened Homebrew build environment that uses years-battle-hardened
build logic to help your `./configure && make && make install` build logic to help your `./configure && make && make install`
@ -1404,7 +1404,7 @@ If no options are passed, use `origin/master` as the start commit.
* `--before`: * `--before`:
Use the commit at the specified *`date`* as the start commit. Use the commit at the specified *`date`* as the start commit.
### `vendor-gems` [*`--update`*`=`*`update`*] ### `vendor-gems` [*`--update`*`=`]
Install and commit Homebrew's vendored gems. Install and commit Homebrew's vendored gems.

View File

@ -518,7 +518,7 @@ Migrate renamed packages to new names, where \fIformula\fR are old names of pack
\fB\-f\fR, \fB\-\-force\fR \fB\-f\fR, \fB\-\-force\fR
Treat installed \fIformula\fR and provided \fIformula\fR as if they are from the same taps and migrate them anyway\. Treat installed \fIformula\fR and provided \fIformula\fR as if they are from the same taps and migrate them anyway\.
. .
.SS "\fBmissing\fR [\fI\-\-hide\fR\fB=\fR\fIhide\fR] [\fIformula\fR \.\.\.]" .SS "\fBmissing\fR [\fI\-\-hide\fR\fB=\fR] [\fIformula\fR \.\.\.]"
Check the given \fIformula\fR kegs for missing dependencies\. If no \fIformula\fR are provided, check all kegs\. Will exit with a non\-zero status if any kegs are found to be missing dependencies\. Check the given \fIformula\fR kegs for missing dependencies\. If no \fIformula\fR are provided, check all kegs\. Will exit with a non\-zero status if any kegs are found to be missing dependencies\.
. .
.TP .TP
@ -746,7 +746,7 @@ Migrate tapped formulae from symlink\-based to directory\-based structure\.
\fB\-\-list\-pinned\fR \fB\-\-list\-pinned\fR
List all pinned taps\. List all pinned taps\.
. .
.SS "\fBtap\-info\fR [\fI\-\-installed\fR] [\fI\-\-json\fR\fB=\fR\fIjson\fR] [\fItap\fR \.\.\.]" .SS "\fBtap\-info\fR [\fI\-\-installed\fR] [\fI\-\-json\fR] [\fItap\fR \.\.\.]"
Show detailed information about one or more \fItap\fRs\. Show detailed information about one or more \fItap\fRs\.
. .
.P .P
@ -964,7 +964,7 @@ Display Homebrew\'s Cellar path\. \fIDefault:\fR \fB$(brew \-\-prefix)/Cellar\fR
.P .P
If \fIformula\fR is provided, display the location in the Cellar where \fIformula\fR would be installed, without any sort of versioned directory as the last path\. If \fIformula\fR is provided, display the location in the Cellar where \fIformula\fR would be installed, without any sort of versioned directory as the last path\.
. .
.SS "\fB\-\-env\fR [\fI\-\-shell\fR\fB=\fR\fIshell\fR] [\fI\-\-plain\fR] [\fIformula\fR \.\.\.]" .SS "\fB\-\-env\fR [\fI\-\-shell\fR\fB=\fR] [\fI\-\-plain\fR] [\fIformula\fR \.\.\.]"
Summarise Homebrew\'s build environment as a plain list\. Summarise Homebrew\'s build environment as a plain list\.
. .
.P .P
@ -1124,7 +1124,7 @@ When passed with \fB\-\-write\fR, a new commit will not generated after writing
\fB\-\-root\-url\fR \fB\-\-root\-url\fR
Use the specified \fIURL\fR as the root of the bottle\'s URL instead of Homebrew\'s default\. Use the specified \fIURL\fR as the root of the bottle\'s URL instead of Homebrew\'s default\.
. .
.SS "\fBbump\fR [\fI\-\-limit\fR\fB=\fR\fIlimit\fR] [\fIformula\fR \.\.\.]" .SS "\fBbump\fR [\fI\-\-limit\fR\fB=\fR] [\fIformula\fR \.\.\.]"
Display out\-of\-date brew formulae and the latest version available\. Also displays whether a pull request has been opened with the URL\. Display out\-of\-date brew formulae and the latest version available\. Also displays whether a pull request has been opened with the URL\.
. .
.TP .TP
@ -1268,7 +1268,7 @@ Specify the new commit \fIrevision\fR corresponding to the specified git \fItag\
\fB\-f\fR, \fB\-\-force\fR \fB\-f\fR, \fB\-\-force\fR
Ignore duplicate open PRs\. Remove all mirrors if \fB\-\-mirror\fR was not specified\. Ignore duplicate open PRs\. Remove all mirrors if \fB\-\-mirror\fR was not specified\.
. .
.SS "\fBbump\-revision\fR [\fI\-\-dry\-run\fR] [\fI\-\-message\fR\fB=\fR\fImessage\fR] \fIformula\fR [\.\.\.]" .SS "\fBbump\-revision\fR [\fI\-\-dry\-run\fR] [\fI\-\-message\fR\fB=\fR] \fIformula\fR [\.\.\.]"
Create a commit to increment the revision of \fIformula\fR\. If no revision is present, "revision 1" will be added\. Create a commit to increment the revision of \fIformula\fR\. If no revision is present, "revision 1" will be added\.
. .
.TP .TP
@ -1417,7 +1417,7 @@ Treat all named arguments as formulae\.
\fB\-\-cask\fR \fB\-\-cask\fR
Treat all named arguments as casks\. Treat all named arguments as casks\.
. .
.SS "\fBextract\fR [\fI\-\-version\fR\fB=\fR\fIversion\fR] [\fI\-\-force\fR] \fIformula\fR \.\.\." .SS "\fBextract\fR [\fI\-\-version\fR\fB=\fR] [\fI\-\-force\fR] \fIformula\fR \.\.\."
Look through repository history to find the most recent version of \fIformula\fR and create a copy in \fItap\fR\fB/Formula/\fR\fIformula\fR\fB@\fR\fIversion\fR\fB\.rb\fR\. If the tap is not installed yet, attempt to install/clone the tap before continuing\. To extract a formula from a tap that is not \fBhomebrew/core\fR use its fully\-qualified form of \fIuser\fR\fB/\fR\fIrepo\fR\fB/\fR\fIformula\fR\. Look through repository history to find the most recent version of \fIformula\fR and create a copy in \fItap\fR\fB/Formula/\fR\fIformula\fR\fB@\fR\fIversion\fR\fB\.rb\fR\. If the tap is not installed yet, attempt to install/clone the tap before continuing\. To extract a formula from a tap that is not \fBhomebrew/core\fR use its fully\-qualified form of \fIuser\fR\fB/\fR\fIrepo\fR\fB/\fR\fIformula\fR\.
. .
.TP .TP
@ -1707,7 +1707,7 @@ Load a library using \fBrequire\fR\.
\fB\-e\fR \fB\-e\fR
Execute the given text string as a script\. Execute the given text string as a script\.
. .
.SS "\fBsh\fR [\fI\-\-env\fR\fB=\fR\fIenv\fR] [\fI\-\-cmd\fR\fB=\fR\fIcmd\fR] [\fIfile\fR]" .SS "\fBsh\fR [\fI\-\-env\fR\fB=\fR] [\fI\-\-cmd\fR\fB=\fR] [\fIfile\fR]"
Homebrew build environment that uses years\-battle\-hardened build logic to help your \fB\./configure && make && make install\fR and even your \fBgem install\fR succeed\. Especially handy if you run Homebrew in an Xcode\-only configuration since it adds tools like \fBmake\fR to your \fBPATH\fR which build systems would not find otherwise\. Homebrew build environment that uses years\-battle\-hardened build logic to help your \fB\./configure && make && make install\fR and even your \fBgem install\fR succeed\. Especially handy if you run Homebrew in an Xcode\-only configuration since it adds tools like \fBmake\fR to your \fBPATH\fR which build systems would not find otherwise\.
. .
.TP .TP
@ -1945,7 +1945,7 @@ Use the specified \fIcommit\fR as the start commit\.
\fB\-\-before\fR \fB\-\-before\fR
Use the commit at the specified \fIdate\fR as the start commit\. Use the commit at the specified \fIdate\fR as the start commit\.
. .
.SS "\fBvendor\-gems\fR [\fI\-\-update\fR\fB=\fR\fIupdate\fR]" .SS "\fBvendor\-gems\fR [\fI\-\-update\fR\fB=\fR]"
Install and commit Homebrew\'s vendored gems\. Install and commit Homebrew\'s vendored gems\.
. .
.TP .TP