From d3959727d69cac111d04b5c22aef3e2a4c69556b Mon Sep 17 00:00:00 2001 From: Eric Knibbe Date: Sat, 7 Oct 2023 23:47:00 -0400 Subject: [PATCH 1/2] cli/parser: depopulate commands' args lists --- Library/Homebrew/cli/parser.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index fd0a64e2be..3e997448f7 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -515,8 +515,8 @@ module Homebrew end end - def disable_switch(*names) - names.each do |name| + def disable_switch(*args) + args.each do |name| @args["#{option_to_name(name)}?"] = if name.start_with?("--[no-]") nil else @@ -614,6 +614,7 @@ module Homebrew @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] + args.select! { |a| a.start_with?("-") } if type == :switch disable_switch(*args) else From abeab3e6c6440dd10a122fdfc5cb884cf0c854ef Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 8 Oct 2023 19:12:43 +0100 Subject: [PATCH 2/2] cli/parser: tweak style. Co-authored-by: Kevin --- Library/Homebrew/cli/parser.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index 3e997448f7..c667283ac0 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -614,7 +614,7 @@ module Homebrew @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] - args.select! { |a| a.start_with?("-") } + args.pop # last argument is the description if type == :switch disable_switch(*args) else