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)
|
def process_option(*args)
|
||||||
option, = @parser.make_switch(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]
|
@processed_options << [option.short.first, option.long.first, option.arg, option.desc.first]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -39,8 +39,10 @@ module Homebrew
|
|||||||
puts_options Formula.to_a.sort, args: args
|
puts_options Formula.to_a.sort, args: args
|
||||||
elsif args.installed?
|
elsif args.installed?
|
||||||
puts_options Formula.installed.sort, args: args
|
puts_options Formula.installed.sort, args: args
|
||||||
elsif !args.command.nil?
|
elsif args.command.present?
|
||||||
cmd_options = Commands.command_options(args.command)
|
cmd_options = Commands.command_options(args.command)
|
||||||
|
odie "Unknown command: #{args.command}" if cmd_options.nil?
|
||||||
|
|
||||||
if args.compact?
|
if args.compact?
|
||||||
puts cmd_options.sort.map(&:first) * " "
|
puts cmd_options.sort.map(&:first) * " "
|
||||||
else
|
else
|
||||||
|
|||||||
@ -197,7 +197,7 @@ module Commands
|
|||||||
HOMEBREW_CACHE.mkpath
|
HOMEBREW_CACHE.mkpath
|
||||||
|
|
||||||
cmds = commands(aliases: true).reject do |cmd|
|
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)
|
cmd.start_with?("cask ") || Homebrew::Completions::COMPLETIONS_EXCLUSION_LIST.include?(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -206,8 +206,8 @@ module Commands
|
|||||||
end
|
end
|
||||||
|
|
||||||
def command_options(command)
|
def command_options(command)
|
||||||
path = Commands.path(command)
|
path = self.path(command)
|
||||||
return unless path
|
return if path.blank?
|
||||||
|
|
||||||
if cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path)
|
if cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path)
|
||||||
cmd_parser.processed_options.map do |short, long, _, desc|
|
cmd_parser.processed_options.map do |short, long, _, desc|
|
||||||
@ -229,8 +229,8 @@ module Commands
|
|||||||
end
|
end
|
||||||
|
|
||||||
def named_args_type(command)
|
def named_args_type(command)
|
||||||
path = Commands.path(command)
|
path = self.path(command)
|
||||||
return unless path
|
return if path.blank?
|
||||||
|
|
||||||
cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path)
|
cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path)
|
||||||
return if cmd_parser.blank?
|
return if cmd_parser.blank?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user