usage string generator: fix handling of dashed-commands

This commit is contained in:
Rylan Polster 2021-01-18 12:57:35 -05:00
parent c8d32ff75a
commit 1e4fef8123
No known key found for this signature in database
GPG Key ID: 46A744940CFF4D64
3 changed files with 9 additions and 9 deletions

View File

@ -122,7 +122,7 @@ module Homebrew
@args = Homebrew::CLI::Args.new @args = Homebrew::CLI::Args.new
@command_name = caller_locations(2, 1).first.label.chomp("_args") @command_name = caller_locations(2, 1).first.label.chomp("_args").tr("_", "-")
@constraints = [] @constraints = []
@conflicts = [] @conflicts = []
@ -449,12 +449,12 @@ module Homebrew
}.freeze }.freeze
def generate_usage_banner def generate_usage_banner
command_names = ["`#{@command_name.tr("_", "-")}`"] command_names = ["`#{@command_name}`"]
aliases_to_skip = %w[instal uninstal] aliases_to_skip = %w[instal uninstal]
command_names += Commands::HOMEBREW_INTERNAL_COMMAND_ALIASES.map do |command_alias, command| command_names += Commands::HOMEBREW_INTERNAL_COMMAND_ALIASES.map do |command_alias, command|
next if aliases_to_skip.include? command_alias next if aliases_to_skip.include? command_alias
"`#{command_alias.tr("_", "-")}`" if command == @command_name "`#{command_alias}`" if command == @command_name
end.compact.sort end.compact.sort
options = if @non_global_processed_options.empty? options = if @non_global_processed_options.empty?

View File

@ -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`*`=`] [*`--plain`*] [*`formula`* ...] ### `--env`, `environment` [*`--shell`*`=`] [*`--plain`*] [*`formula`* ...]
Summarise Homebrew's build environment as a plain list. Summarise Homebrew's build environment as a plain list.
@ -737,13 +737,13 @@ is or would be installed.
* `--unbrewed`: * `--unbrewed`:
List files in Homebrew's prefix not installed by Homebrew. List files in Homebrew's prefix not installed by Homebrew.
### `--repository` [*`tap`* ...] ### `--repository`, `--repo` [*`tap`* ...]
Display where Homebrew's `.git` directory is located. Display where Homebrew's `.git` directory is located.
If *`user`*`/`*`repo`* are provided, display where tap *`user`*`/`*`repo`*'s directory is located. If *`user`*`/`*`repo`* are provided, display where tap *`user`*`/`*`repo`*'s directory is located.
### `--version` ### `--version`, `-v`
Print the version numbers of Homebrew, Homebrew/homebrew-core and Homebrew/homebrew-cask Print the version numbers of Homebrew, Homebrew/homebrew-core and Homebrew/homebrew-cask
(if tapped) to standard output. (if tapped) to standard output.

View File

@ -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] [\fI\-\-plain\fR] [\fIformula\fR \.\.\.]" .SS "\fB\-\-env\fR, \fBenvironment\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
@ -999,13 +999,13 @@ If \fIformula\fR is provided, display the location in the Cellar where \fIformul
\fB\-\-unbrewed\fR \fB\-\-unbrewed\fR
List files in Homebrew\'s prefix not installed by Homebrew\. List files in Homebrew\'s prefix not installed by Homebrew\.
. .
.SS "\fB\-\-repository\fR [\fItap\fR \.\.\.]" .SS "\fB\-\-repository\fR, \fB\-\-repo\fR [\fItap\fR \.\.\.]"
Display where Homebrew\'s \fB\.git\fR directory is located\. Display where Homebrew\'s \fB\.git\fR directory is located\.
. .
.P .P
If \fIuser\fR\fB/\fR\fIrepo\fR are provided, display where tap \fIuser\fR\fB/\fR\fIrepo\fR\'s directory is located\. If \fIuser\fR\fB/\fR\fIrepo\fR are provided, display where tap \fIuser\fR\fB/\fR\fIrepo\fR\'s directory is located\.
. .
.SS "\fB\-\-version\fR" .SS "\fB\-\-version\fR, \fB\-v\fR"
Print the version numbers of Homebrew, Homebrew/homebrew\-core and Homebrew/homebrew\-cask (if tapped) to standard output\. Print the version numbers of Homebrew, Homebrew/homebrew\-core and Homebrew/homebrew\-cask (if tapped) to standard output\.
. .
.SH "DEVELOPER COMMANDS" .SH "DEVELOPER COMMANDS"