Skip to content

Commit

Permalink
Remove unused processed option element
Browse files Browse the repository at this point in the history
  • Loading branch information
dduugg committed Aug 19, 2024
1 parent 4bbad3c commit 7acddd7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
7 changes: 3 additions & 4 deletions Library/Homebrew/cli/args.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ class Args < OpenStruct
# Represents a processed option. The array elements are:
# 0: short option name (e.g. "-d")
# 1: long option name (e.g. "--debug")
# 2: ???
# 3: option description (e.g. "Print debugging information")
# 4: whether the option is hidden)
OptionsType = T.type_alias { T::Array[[String, T.nilable(String), NilClass, String, T::Boolean]] }
# 2: option description (e.g. "Print debugging information")
# 3: whether the option is hidden
OptionsType = T.type_alias { T::Array[[String, T.nilable(String), String, T::Boolean]] }
# rubocop:enable Style/MutableConstant

sig { returns(T::Array[String]) }
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cli/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ def check_named_args(args)
def process_option(*args, type:, hidden: false)
option, = @parser.make_switch(args)
@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, hidden]
@processed_options << [option.short.first, option.long.first, option.desc.first, hidden]

args.pop # last argument is the description
if type == :switch
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def self.command_options(command)
return if path.blank?

if (cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path))
cmd_parser.processed_options.filter_map do |short, long, _, desc, hidden|
cmd_parser.processed_options.filter_map do |short, long, desc, hidden|
next if hidden

[long || short, desc]
Expand Down
3 changes: 2 additions & 1 deletion Library/Homebrew/manpages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ def self.generate_cmd_manpages(cmd_paths)
man_page_lines.compact.join("\n")
end

sig { params(cmd_parser: CLI::Parser).returns(T::Array[String]) }
def self.cmd_parser_manpage_lines(cmd_parser)
lines = [format_usage_banner(cmd_parser.usage_banner_text)]
lines += cmd_parser.processed_options.filter_map do |short, long, _, desc, hidden|
lines += cmd_parser.processed_options.filter_map do |short, long, desc, hidden|

Check warning on line 102 in Library/Homebrew/manpages.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/manpages.rb#L102

Added line #L102 was not covered by tests
next if hidden

if long.present?
Expand Down

0 comments on commit 7acddd7

Please sign in to comment.