command: Use CLI::Parser to parse args

This commit is contained in:
Gautham Goli 2019-01-20 20:08:14 +05:30
parent 70c5b6f804
commit b1a36a13e2
No known key found for this signature in database
GPG Key ID: 6A9ABBC284468364

View File

@ -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)