From 7acddd7eb2b6c7449bfa3e943ae469115b25e6fa Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Mon, 19 Aug 2024 13:15:34 -0700 Subject: [PATCH] Remove unused processed option element --- Library/Homebrew/cli/args.rb | 7 +++---- Library/Homebrew/cli/parser.rb | 2 +- Library/Homebrew/commands.rb | 2 +- Library/Homebrew/manpages.rb | 3 ++- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/cli/args.rb b/Library/Homebrew/cli/args.rb index ea688f09f3..709a84e77f 100644 --- a/Library/Homebrew/cli/args.rb +++ b/Library/Homebrew/cli/args.rb @@ -11,10 +11,9 @@ module Homebrew # 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]) } diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index b8edc0ab67..79db0ede47 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -670,7 +670,7 @@ module Homebrew 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 diff --git a/Library/Homebrew/commands.rb b/Library/Homebrew/commands.rb index bd15e09d2b..bff04823ef 100644 --- a/Library/Homebrew/commands.rb +++ b/Library/Homebrew/commands.rb @@ -199,7 +199,7 @@ module Commands 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] diff --git a/Library/Homebrew/manpages.rb b/Library/Homebrew/manpages.rb index f49184cf12..3b3048017f 100644 --- a/Library/Homebrew/manpages.rb +++ b/Library/Homebrew/manpages.rb @@ -96,9 +96,10 @@ module Homebrew 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| next if hidden if long.present?