Incorporate suggestions from code review
Co-Authored-By: Seeker <meaningseeking@protonmail.com>
This commit is contained in:
parent
3af16832d9
commit
eebc161ea5
@ -539,7 +539,7 @@ module Homebrew
|
||||
|
||||
def process_option(*args)
|
||||
option, = @parser.make_switch(args)
|
||||
@processed_options.reject! { |existing| option.long.first.present? && existing.second == option.long.first }
|
||||
@processed_options.reject! { |existing| existing.second == option.long.first } if option.long.first.present?
|
||||
@processed_options << [option.short.first, option.long.first, option.arg, option.desc.first]
|
||||
end
|
||||
|
||||
|
||||
@ -39,8 +39,10 @@ module Homebrew
|
||||
puts_options Formula.to_a.sort, args: args
|
||||
elsif args.installed?
|
||||
puts_options Formula.installed.sort, args: args
|
||||
elsif !args.command.nil?
|
||||
elsif args.command.present?
|
||||
cmd_options = Commands.command_options(args.command)
|
||||
odie "Unknown command: #{args.command}" if cmd_options.nil?
|
||||
|
||||
if args.compact?
|
||||
puts cmd_options.sort.map(&:first) * " "
|
||||
else
|
||||
|
||||
@ -197,7 +197,7 @@ module Commands
|
||||
HOMEBREW_CACHE.mkpath
|
||||
|
||||
cmds = commands(aliases: true).reject do |cmd|
|
||||
# TODO: remove the cask check when `brew cask` is removed
|
||||
# TODO: (2.8) remove the cask check when `brew cask` is removed
|
||||
cmd.start_with?("cask ") || Homebrew::Completions::COMPLETIONS_EXCLUSION_LIST.include?(cmd)
|
||||
end
|
||||
|
||||
@ -206,8 +206,8 @@ module Commands
|
||||
end
|
||||
|
||||
def command_options(command)
|
||||
path = Commands.path(command)
|
||||
return unless path
|
||||
path = self.path(command)
|
||||
return if path.blank?
|
||||
|
||||
if cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path)
|
||||
cmd_parser.processed_options.map do |short, long, _, desc|
|
||||
@ -229,8 +229,8 @@ module Commands
|
||||
end
|
||||
|
||||
def named_args_type(command)
|
||||
path = Commands.path(command)
|
||||
return unless path
|
||||
path = self.path(command)
|
||||
return if path.blank?
|
||||
|
||||
cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path)
|
||||
return if cmd_parser.blank?
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user