commands: fix completion descriptions
Currently, zsh and fish shell completions show incomplete descriptions
for certain commands. For example:
docs -- Open Homebrew's online documentation (https://docs
rbenv-sync -- Create symlinks for Homebrew's installed Ruby versions in ~/
This is because `Commands.command_description` produces incomplete
short descriptions for the commands having a dot (from a URL or a path)
in the first sentence; the dot is misinterpreted as a full stop:
brew(main):001:0> Commands.command_description("docs", short: true)
=> "Open Homebrew's online documentation (https://docs"
brew(main):002:0> Commands.command_description("rbenv-sync", short: true)
=> "Create symlinks for Homebrew's installed Ruby versions in ~/"
We can improve the sentence splitting logic by only splitting at dots
either at the end or followed by a whitespace. Now With this change:
brew(main):001:0> Commands.command_description("docs", short: true)
=> "Open Homebrew's online documentation (https://docs.brew.sh) in a browser"
brew(main):002:0> Commands.command_description("rbenv-sync", short: true)
=> "Create symlinks for Homebrew's installed Ruby versions in ~/.rbenv/versions"
Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
This commit is contained in:
parent
7dbe1b4877
commit
68b63427c6
@ -203,7 +203,7 @@ module Commands
|
||||
|
||||
if (cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path))
|
||||
if short
|
||||
cmd_parser.description.split(".").first
|
||||
cmd_parser.description.split(/\.(?>\s|$)/).first
|
||||
else
|
||||
cmd_parser.description
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user