command: Use CLI::Parser to parse args
This commit is contained in:
parent
70c5b6f804
commit
b1a36a13e2
@ -2,14 +2,28 @@
|
|||||||
#: Display the path to the file which is used when invoking `brew` <cmd>.
|
#: Display the path to the file which is used when invoking `brew` <cmd>.
|
||||||
|
|
||||||
require "commands"
|
require "commands"
|
||||||
|
require "cli_parser"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def command
|
def command_args
|
||||||
abort "This command requires a command argument" if ARGV.empty?
|
Homebrew::CLI::Parser.new do
|
||||||
|
usage_banner <<~EOS
|
||||||
|
`command` <cmd>
|
||||||
|
|
||||||
cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(ARGV.first, ARGV.first)
|
Display the path to the file which is used when invoking `brew` <cmd>.
|
||||||
|
EOS
|
||||||
|
switch :verbose
|
||||||
|
switch :debug
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def command
|
||||||
|
command_args.parse
|
||||||
|
abort "This command requires a command argument" if args.remaining.empty?
|
||||||
|
|
||||||
|
cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(args.remaining.first, args.remaining.first)
|
||||||
|
|
||||||
path = Commands.path(cmd)
|
path = Commands.path(cmd)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user