2020-11-25 17:03:23 +01:00
|
|
|
# typed: true
|
2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-09-07 20:09:22 +01:00
|
|
|
require "commands"
|
2019-04-17 18:25:08 +09:00
|
|
|
require "cli/parser"
|
2016-09-07 20:09:22 +01:00
|
|
|
|
2015-06-26 15:19:27 +08:00
|
|
|
module Homebrew
|
2020-10-20 12:03:48 +02:00
|
|
|
extend T::Sig
|
|
|
|
|
2016-09-26 01:44:51 +02:00
|
|
|
module_function
|
|
|
|
|
2020-10-20 12:03:48 +02:00
|
|
|
sig { returns(CLI::Parser) }
|
2019-01-20 20:08:14 +05:30
|
|
|
def command_args
|
|
|
|
Homebrew::CLI::Parser.new do
|
|
|
|
usage_banner <<~EOS
|
2021-01-15 13:04:07 +01:00
|
|
|
`command` <cmd> [<cmd> ...]
|
2019-01-20 20:08:14 +05:30
|
|
|
|
2019-08-20 00:04:14 -04:00
|
|
|
Display the path to the file being used when invoking `brew` <cmd>.
|
2019-01-20 20:08:14 +05:30
|
|
|
EOS
|
2020-07-30 18:40:10 +02:00
|
|
|
|
2021-01-10 14:26:40 -05:00
|
|
|
named_args :command, min: 1
|
2019-01-20 20:08:14 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-06-26 15:19:27 +08:00
|
|
|
def command
|
2020-07-30 18:40:10 +02:00
|
|
|
args = command_args.parse
|
2015-06-26 15:19:27 +08:00
|
|
|
|
2020-03-04 17:28:15 +00:00
|
|
|
args.named.each do |cmd|
|
2019-12-13 16:57:57 -05:00
|
|
|
path = Commands.path(cmd)
|
|
|
|
odie "Unknown command: #{cmd}" unless path
|
|
|
|
puts path
|
|
|
|
end
|
2015-06-26 15:19:27 +08:00
|
|
|
end
|
|
|
|
end
|