commands: Use CLI::Parser to parse args
This commit is contained in:
parent
70c5b6f804
commit
c5f01f203a
@ -4,15 +4,36 @@
|
|||||||
#: If `--quiet` is passed, list only the names of commands without the header.
|
#: If `--quiet` is passed, list only the names of commands without the header.
|
||||||
#: With `--include-aliases`, the aliases of internal commands will be included.
|
#: With `--include-aliases`, the aliases of internal commands will be included.
|
||||||
|
|
||||||
|
require "cli_parser"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
|
def commands_args
|
||||||
|
Homebrew::CLI::Parser.new do
|
||||||
|
usage_banner <<~EOS
|
||||||
|
`commands` [<options>]
|
||||||
|
|
||||||
|
Show a list of built-in and external commands.
|
||||||
|
EOS
|
||||||
|
switch "--quiet",
|
||||||
|
description: "List only the names of commands without the header."
|
||||||
|
switch "--include-aliases",
|
||||||
|
depends_on: "--quiet",
|
||||||
|
description: "Include the aliases of internal commands."
|
||||||
|
switch :verbose
|
||||||
|
switch :debug
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def commands
|
def commands
|
||||||
if ARGV.include? "--quiet"
|
commands_args.parse
|
||||||
|
|
||||||
|
if args.quiet?
|
||||||
cmds = internal_commands
|
cmds = internal_commands
|
||||||
cmds += external_commands
|
cmds += external_commands
|
||||||
cmds += internal_developer_commands
|
cmds += internal_developer_commands
|
||||||
cmds += HOMEBREW_INTERNAL_COMMAND_ALIASES.keys if ARGV.include? "--include-aliases"
|
cmds += HOMEBREW_INTERNAL_COMMAND_ALIASES.keys if args.include_aliases?
|
||||||
puts Formatter.columns(cmds.sort)
|
puts Formatter.columns(cmds.sort)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user