From a9a0c415e7fbbe3db263990b5ef075d052043ff6 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Mon, 18 Jan 2021 11:03:23 -0500 Subject: [PATCH] Cleanup usage strings for flags --- Library/Homebrew/cli/parser.rb | 13 +++++++------ docs/Manpage.md | 16 ++++++++-------- manpages/brew.1 | 16 ++++++++-------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index b46fc0487c..9fc4ad3300 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -206,15 +206,15 @@ module Homebrew end def flag(*names, description: nil, replacement: nil, required_for: nil, depends_on: nil) - required = if names.any? { |name| name.end_with? "=" } - OptionParser::REQUIRED_ARGUMENT + required, flag_type = if names.any? { |name| name.end_with? "=" } + [OptionParser::REQUIRED_ARGUMENT, :required_flag] else - OptionParser::OPTIONAL_ARGUMENT + [OptionParser::OPTIONAL_ARGUMENT, :optional_flag] end names.map! { |name| name.chomp "=" } description = option_to_description(*names) if description.nil? if replacement.nil? - process_option(*names, description, type: :flag) + process_option(*names, description, type: flag_type) else description += " (disabled#{"; replaced by #{replacement}" if replacement.present?})" end @@ -462,10 +462,11 @@ module Homebrew elsif @non_global_processed_options.count > 2 " []" else + required_argument_types = [:required_flag, :comma_array] @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 diff --git a/docs/Manpage.md b/docs/Manpage.md index 0965c2d2ad..e90d3de15a 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -382,7 +382,7 @@ packages. * `-f`, `--force`: 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 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 all pinned taps. -### `tap-info` [*`--installed`*] [*`--json`*`=`*`json`*] [*`tap`* ...] +### `tap-info` [*`--installed`*] [*`--json`*] [*`tap`* ...] 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`* 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. @@ -821,7 +821,7 @@ value, while `--no-rebuild` will remove it. * `--root-url`: 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. 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`: 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 present, "revision 1" will be added. @@ -1019,7 +1019,7 @@ or open the Homebrew repository for editing if no formula is provided. * `--cask`: 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 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`: 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 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`: 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. diff --git a/manpages/brew.1 b/manpages/brew.1 index 94aeb47c7c..40e71d44cd 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -518,7 +518,7 @@ Migrate renamed packages to new names, where \fIformula\fR are old names of pack \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\. . -.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\. . .TP @@ -746,7 +746,7 @@ Migrate tapped formulae from symlink\-based to directory\-based structure\. \fB\-\-list\-pinned\fR 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\. . .P @@ -964,7 +964,7 @@ Display Homebrew\'s Cellar path\. \fIDefault:\fR \fB$(brew \-\-prefix)/Cellar\fR .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\. . -.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\. . .P @@ -1124,7 +1124,7 @@ When passed with \fB\-\-write\fR, a new commit will not generated after writing \fB\-\-root\-url\fR 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\. . .TP @@ -1268,7 +1268,7 @@ Specify the new commit \fIrevision\fR corresponding to the specified git \fItag\ \fB\-f\fR, \fB\-\-force\fR 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\. . .TP @@ -1417,7 +1417,7 @@ Treat all named arguments as formulae\. \fB\-\-cask\fR 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\. . .TP @@ -1707,7 +1707,7 @@ Load a library using \fBrequire\fR\. \fB\-e\fR 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\. . .TP @@ -1945,7 +1945,7 @@ Use the specified \fIcommit\fR as the start commit\. \fB\-\-before\fR 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\. . .TP