Merge pull request #5568 from GauthamGoli/commands-args
commands: Use CLI::Parser to parse args
This commit is contained in:
commit
4cf2bd2269
@ -4,15 +4,36 @@
|
||||
#: If `--quiet` is passed, list only the names of commands without the header.
|
||||
#: With `--include-aliases`, the aliases of internal commands will be included.
|
||||
|
||||
require "cli_parser"
|
||||
|
||||
module Homebrew
|
||||
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
|
||||
if ARGV.include? "--quiet"
|
||||
commands_args.parse
|
||||
|
||||
if args.quiet?
|
||||
cmds = internal_commands
|
||||
cmds += external_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)
|
||||
return
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user