From 868c15fe4f5020182cd46e915fed631e3d534d9e Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Mon, 22 Apr 2024 11:58:07 +0800 Subject: [PATCH 01/12] cmd/list: support listing formulae installed on request or automatically Sample usage: $ brew ls --manual gcc llvm [...] $ brew ls --auto grpc protobuf [...] $ brew ls --manual --auto gcc: manual grpc: auto llvm: manual protobuf: auto [...] Resolves #17117. --- Library/Homebrew/cmd/list.rb | 31 ++++++++++++++++++++- Library/Homebrew/test/cmd/list_spec.rb | 37 ++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index 619bc49feb..e1e2e8b01c 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -7,6 +7,7 @@ require "formula" require "cli/parser" require "cask/list" require "system_command" +require "tab" module Homebrew module Cmd @@ -36,6 +37,11 @@ module Homebrew switch "--pinned", description: "List only pinned formulae, or only the specified (pinned) " \ "formulae if are provided. See also `pin`, `unpin`." + switch "--manual", "--installed-on-request", + description: "List the formulae installed on request." + switch "--auto", "--installed-as-dependency", + description: "List the formulae installed automatically." + # passed through to ls switch "-1", description: "Force output to be one entry per line. " \ @@ -54,11 +60,17 @@ module Homebrew conflicts "--pinned", "--cask" conflicts "--multiple", "--cask" conflicts "--pinned", "--multiple" + ["--manual", "--auto"].each do |flag| + conflicts "--cask", flag + conflicts "--versions", flag + conflicts "--pinned", flag + end ["-1", "-l", "-r", "-t"].each do |flag| conflicts "--versions", flag conflicts "--pinned", flag end - ["--versions", "--pinned", "-l", "-r", "-t"].each do |flag| + ["--versions", "--pinned", "--manual", "--auto", + "-l", "-r", "-t"].each do |flag| conflicts "--full-name", flag end @@ -91,6 +103,23 @@ module Homebrew elsif args.versions? filtered_list unless args.cask? list_casks if args.cask? || (!args.formula? && !args.multiple? && args.no_named?) + elsif args.manual? || args.auto? + unless args.no_named? + raise UsageError, + "Cannot use `--manual` or `--auto` with formula arguments." + end + + Formula.installed.sort.each do |formula| + tab = Tab.for_formula(formula) + + if args.manual? && args.auto? + status = tab.installed_on_request ? "manual" : "auto" + puts "#{formula.name}: #{status}" + elsif (args.manual? && tab.installed_on_request) || + (args.auto? && !tab.installed_on_request) + puts formula.name + end + end elsif args.no_named? ENV["CLICOLOR"] = nil diff --git a/Library/Homebrew/test/cmd/list_spec.rb b/Library/Homebrew/test/cmd/list_spec.rb index b5b4a52902..3ca3e9a15a 100644 --- a/Library/Homebrew/test/cmd/list_spec.rb +++ b/Library/Homebrew/test/cmd/list_spec.rb @@ -2,8 +2,24 @@ require "cmd/list" require "cmd/shared_examples/args_parse" +require "tab" RSpec.describe Homebrew::Cmd::List do + def setup_installation(formula_name, installed_on_request:) + setup_test_formula(formula_name) + + keg_dir = HOMEBREW_CELLAR/formula_name/"1.0" + keg_dir.mkpath + + tab = Tab.new( + "installed_on_request" => installed_on_request, + "tabfile" => keg_dir/Tab::FILENAME, + ) + tab.write + + keg_dir + end + let(:formulae) { %w[bar foo qux] } it_behaves_like "parseable arguments" @@ -18,4 +34,25 @@ RSpec.describe Homebrew::Cmd::List do .and not_to_output.to_stderr .and be_a_success end + + it "lists the formulae installed on request or automatically", + :integration_test do + setup_installation "foo", installed_on_request: true + setup_installation "bar", installed_on_request: false + + expect { brew "list", "--manual" } + .to be_a_success + .and output("foo\n").to_stdout + .and not_to_output.to_stderr + + expect { brew "list", "--auto" } + .to be_a_success + .and output("bar\n").to_stdout + .and not_to_output.to_stderr + + expect { brew "list", "--manual", "--auto" } + .to be_a_success + .and output("bar: auto\nfoo: manual\n").to_stdout + .and not_to_output.to_stderr + end end From 5e63d3188fa476f0b7bc04a5c94917cdd8780d55 Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Mon, 22 Apr 2024 12:01:26 +0800 Subject: [PATCH 02/12] brew tc --update --- .../Homebrew/sorbet/rbi/dsl/homebrew/cmd/list.rbi | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/list.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/list.rbi index a5b8ec328e..13734e1e12 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/list.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/list.rbi @@ -5,6 +5,9 @@ # Please instead update this file by running `bin/tapioca dsl Homebrew::Cmd::List`. class Homebrew::CLI::Args + sig { returns(T::Boolean) } + def auto?; end + sig { returns(T::Boolean) } def cask?; end @@ -20,9 +23,18 @@ class Homebrew::CLI::Args sig { returns(T::Boolean) } def full_name?; end + sig { returns(T::Boolean) } + def installed_as_dependency?; end + + sig { returns(T::Boolean) } + def installed_on_request?; end + sig { returns(T::Boolean) } def l?; end + sig { returns(T::Boolean) } + def manual?; end + sig { returns(T::Boolean) } def multiple?; end From a6268a19d676dc2abaafec9b419cd8a3fa2f220b Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Mon, 22 Apr 2024 12:01:46 +0800 Subject: [PATCH 03/12] Update manpage and completions --- completions/bash/brew | 4 ++++ completions/fish/brew.fish | 4 ++++ completions/zsh/_brew | 20 ++++++++++++-------- docs/Manpage.md | 8 ++++++++ manpages/brew.1 | 6 ++++++ 5 files changed, 34 insertions(+), 8 deletions(-) diff --git a/completions/bash/brew b/completions/bash/brew index 289e52bf87..c5827460cf 100644 --- a/completions/bash/brew +++ b/completions/bash/brew @@ -1415,11 +1415,13 @@ _brew_list() { case "${cur}" in -*) __brewcomp " + --auto --cask --debug --formula --full-name --help + --manual --multiple --pinned --quiet @@ -1517,11 +1519,13 @@ _brew_ls() { case "${cur}" in -*) __brewcomp " + --auto --cask --debug --formula --full-name --help + --manual --multiple --pinned --quiet diff --git a/completions/fish/brew.fish b/completions/fish/brew.fish index ecb629d655..40fa17825c 100644 --- a/completions/fish/brew.fish +++ b/completions/fish/brew.fish @@ -990,11 +990,13 @@ __fish_brew_complete_arg 'linkage' -a '(__fish_brew_suggest_formulae_installed)' __fish_brew_complete_cmd 'list' 'List all installed formulae and casks' +__fish_brew_complete_arg 'list' -l auto -d 'List the formulae installed automatically' __fish_brew_complete_arg 'list' -l cask -d 'List only casks, or treat all named arguments as casks' __fish_brew_complete_arg 'list' -l debug -d 'Display any debugging information' __fish_brew_complete_arg 'list' -l formula -d 'List only formulae, or treat all named arguments as formulae' __fish_brew_complete_arg 'list' -l full-name -d 'Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output' __fish_brew_complete_arg 'list' -l help -d 'Show this message' +__fish_brew_complete_arg 'list' -l manual -d 'List the formulae installed on request' __fish_brew_complete_arg 'list' -l multiple -d 'Only show formulae with multiple versions installed' __fish_brew_complete_arg 'list' -l pinned -d 'List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`' __fish_brew_complete_arg 'list' -l quiet -d 'Make some output more quiet' @@ -1056,11 +1058,13 @@ __fish_brew_complete_arg 'log; and not __fish_seen_argument -l formula -l formul __fish_brew_complete_cmd 'ls' 'List all installed formulae and casks' +__fish_brew_complete_arg 'ls' -l auto -d 'List the formulae installed automatically' __fish_brew_complete_arg 'ls' -l cask -d 'List only casks, or treat all named arguments as casks' __fish_brew_complete_arg 'ls' -l debug -d 'Display any debugging information' __fish_brew_complete_arg 'ls' -l formula -d 'List only formulae, or treat all named arguments as formulae' __fish_brew_complete_arg 'ls' -l full-name -d 'Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output' __fish_brew_complete_arg 'ls' -l help -d 'Show this message' +__fish_brew_complete_arg 'ls' -l manual -d 'List the formulae installed on request' __fish_brew_complete_arg 'ls' -l multiple -d 'Only show formulae with multiple versions installed' __fish_brew_complete_arg 'ls' -l pinned -d 'List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`' __fish_brew_complete_arg 'ls' -l quiet -d 'Make some output more quiet' diff --git a/completions/zsh/_brew b/completions/zsh/_brew index e7536ef77e..87b88286b0 100644 --- a/completions/zsh/_brew +++ b/completions/zsh/_brew @@ -1231,14 +1231,16 @@ _brew_linkage() { # brew list _brew_list() { _arguments \ + '(--cask --versions --pinned --full-name)--auto[List the formulae installed automatically]' \ '--debug[Display any debugging information]' \ - '(--versions --pinned --l --r --t)--full-name[Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output]' \ + '(--versions --pinned --manual --auto --l --r --t)--full-name[Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output]' \ '--help[Show this message]' \ + '(--cask --versions --pinned --full-name)--manual[List the formulae installed on request]' \ '(--cask --pinned)--multiple[Only show formulae with multiple versions installed]' \ - '(--cask --multiple --1 --l --r --t --full-name)--pinned[List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`]' \ + '(--cask --multiple --manual --auto --1 --l --r --t --full-name)--pinned[List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`]' \ '--quiet[Make some output more quiet]' \ '--verbose[Make some output more verbose]' \ - '(--1 --l --r --t --full-name)--versions[Show the version number for installed formulae, or only the specified formulae if formula are provided]' \ + '(--manual --auto --1 --l --r --t --full-name)--versions[Show the version number for installed formulae, or only the specified formulae if formula are provided]' \ '-1[Force output to be one entry per line. This is the default when output is not to a terminal]' \ '-l[List formulae and/or casks in long format. Has no effect when a formula or cask name is passed as an argument]' \ '-r[Reverse the order of the formulae and/or casks sort to list the oldest entries first. Has no effect when a formula or cask name is passed as an argument]' \ @@ -1247,7 +1249,7 @@ _brew_list() { '(--cask)--formula[List only formulae, or treat all named arguments as formulae]' \ '*::installed_formula:__brew_installed_formulae' \ - installed_cask \ - '(--formula --pinned --multiple)--cask[List only casks, or treat all named arguments as casks]' \ + '(--formula --pinned --multiple --manual --auto)--cask[List only casks, or treat all named arguments as casks]' \ '*::installed_cask:__brew_installed_casks' } @@ -1312,14 +1314,16 @@ _brew_log() { # brew ls _brew_ls() { _arguments \ + '(--cask --versions --pinned --full-name)--auto[List the formulae installed automatically]' \ '--debug[Display any debugging information]' \ - '(--versions --pinned --l --r --t)--full-name[Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output]' \ + '(--versions --pinned --manual --auto --l --r --t)--full-name[Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output]' \ '--help[Show this message]' \ + '(--cask --versions --pinned --full-name)--manual[List the formulae installed on request]' \ '(--cask --pinned)--multiple[Only show formulae with multiple versions installed]' \ - '(--cask --multiple --1 --l --r --t --full-name)--pinned[List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`]' \ + '(--cask --multiple --manual --auto --1 --l --r --t --full-name)--pinned[List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`]' \ '--quiet[Make some output more quiet]' \ '--verbose[Make some output more verbose]' \ - '(--1 --l --r --t --full-name)--versions[Show the version number for installed formulae, or only the specified formulae if formula are provided]' \ + '(--manual --auto --1 --l --r --t --full-name)--versions[Show the version number for installed formulae, or only the specified formulae if formula are provided]' \ '-1[Force output to be one entry per line. This is the default when output is not to a terminal]' \ '-l[List formulae and/or casks in long format. Has no effect when a formula or cask name is passed as an argument]' \ '-r[Reverse the order of the formulae and/or casks sort to list the oldest entries first. Has no effect when a formula or cask name is passed as an argument]' \ @@ -1328,7 +1332,7 @@ _brew_ls() { '(--cask)--formula[List only formulae, or treat all named arguments as formulae]' \ '*::installed_formula:__brew_installed_formulae' \ - installed_cask \ - '(--formula --pinned --multiple)--cask[List only casks, or treat all named arguments as casks]' \ + '(--formula --pinned --multiple --manual --auto)--cask[List only casks, or treat all named arguments as casks]' \ '*::installed_cask:__brew_installed_casks' } diff --git a/docs/Manpage.md b/docs/Manpage.md index b4b42f9e8c..6f6da800a0 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -741,6 +741,14 @@ paths within its current keg. If *`cask`* is provided, list its artifacts. : List only pinned formulae, or only the specified (pinned) formulae if *`formula`* are provided. See also `pin`, `unpin`. +`--manual` + +: List the formulae installed on request. + +`--auto` + +: List the formulae installed automatically. + `-1` : Force output to be one entry per line. This is the default when output is not diff --git a/manpages/brew.1 b/manpages/brew.1 index 2415dca39a..9c891eb639 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -464,6 +464,12 @@ Only show formulae with multiple versions installed\. \fB\-\-pinned\fP List only pinned formulae, or only the specified (pinned) formulae if \fIformula\fP are provided\. See also \fBpin\fP, \fBunpin\fP\&\. .TP +\fB\-\-manual\fP +List the formulae installed on request\. +.TP +\fB\-\-auto\fP +List the formulae installed automatically\. +.TP \fB\-1\fP Force output to be one entry per line\. This is the default when output is not to a terminal\. .TP From 15c281984983b33ba9e3f5261a9f94ab6d54b704 Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Mon, 22 Apr 2024 12:25:41 +0800 Subject: [PATCH 04/12] Fix tapioca compiler args test --- Library/Homebrew/test/sorbet/tapioca/compilers/args_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/test/sorbet/tapioca/compilers/args_spec.rb b/Library/Homebrew/test/sorbet/tapioca/compilers/args_spec.rb index e12cadbb49..5e078710b5 100644 --- a/Library/Homebrew/test/sorbet/tapioca/compilers/args_spec.rb +++ b/Library/Homebrew/test/sorbet/tapioca/compilers/args_spec.rb @@ -19,8 +19,10 @@ RSpec.describe Tapioca::Compilers::Args do describe "#args_table" do it "returns a mapping of list args to default values" do expect(compiler.args_table(list_parser).keys).to contain_exactly( - :"1?", :cask?, :casks?, :d?, :debug?, :formula?, :formulae?, :full_name?, :h?, :help?, :l?, :multiple?, - :pinned?, :q?, :quiet?, :r?, :t?, :v?, :verbose?, :versions? + :"1?", :auto?, :cask?, :casks?, :d?, :debug?, :formula?, :formulae?, + :full_name?, :h?, :help?, :installed_as_dependency?, + :installed_on_request?, :l?, :manual?, :multiple?, :pinned?, + :q?, :quiet?, :r?, :t?, :v?, :verbose?, :versions? ) end From 2b09fcd6e44cb1e06e716b782ec095736fb41b21 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 23 Apr 2024 08:35:10 +0100 Subject: [PATCH 05/12] cmd/list: more consistent switches. --- Library/Homebrew/cmd/list.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index e1e2e8b01c..557dd3ebb8 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -37,9 +37,9 @@ module Homebrew switch "--pinned", description: "List only pinned formulae, or only the specified (pinned) " \ "formulae if are provided. See also `pin`, `unpin`." - switch "--manual", "--installed-on-request", + switch "--installed-on-request", description: "List the formulae installed on request." - switch "--auto", "--installed-as-dependency", + switch "--installed-as-dependency", description: "List the formulae installed automatically." # passed through to ls From a1a0cbbf0a0f74c86b838f8136bdd9aaa8e3ae03 Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Tue, 23 Apr 2024 15:41:11 +0800 Subject: [PATCH 06/12] cmd/list: update description for `--installed-as-dependency` Co-authored-by: Kevin --- Library/Homebrew/cmd/list.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index 557dd3ebb8..6cb5c6fdba 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -40,7 +40,7 @@ module Homebrew switch "--installed-on-request", description: "List the formulae installed on request." switch "--installed-as-dependency", - description: "List the formulae installed automatically." + description: "List the formulae only installed indirectly as dependencies." # passed through to ls switch "-1", From 7cf6cb2624f28a54b08c80e49155b605c66b59fd Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Tue, 23 Apr 2024 15:44:02 +0800 Subject: [PATCH 07/12] cmd/list: tweak wording --- Library/Homebrew/cmd/list.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index 6cb5c6fdba..f7bd63d123 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -40,7 +40,7 @@ module Homebrew switch "--installed-on-request", description: "List the formulae installed on request." switch "--installed-as-dependency", - description: "List the formulae only installed indirectly as dependencies." + description: "List the formulae installed as dependencies." # passed through to ls switch "-1", From ba85f92df20fce7a1bfe8011b703fa8fa50e053b Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Tue, 23 Apr 2024 15:45:00 +0800 Subject: [PATCH 08/12] cmd/list: update switches and logic --- Library/Homebrew/cmd/list.rb | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index f7bd63d123..b55cfb10f9 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -60,7 +60,7 @@ module Homebrew conflicts "--pinned", "--cask" conflicts "--multiple", "--cask" conflicts "--pinned", "--multiple" - ["--manual", "--auto"].each do |flag| + ["--installed-on-request", "--installed-as-dependency"].each do |flag| conflicts "--cask", flag conflicts "--versions", flag conflicts "--pinned", flag @@ -69,7 +69,8 @@ module Homebrew conflicts "--versions", flag conflicts "--pinned", flag end - ["--versions", "--pinned", "--manual", "--auto", + ["--versions", "--pinned", + "---installed-on-request", "--installed-as-dependency", "-l", "-r", "-t"].each do |flag| conflicts "--full-name", flag end @@ -103,20 +104,25 @@ module Homebrew elsif args.versions? filtered_list unless args.cask? list_casks if args.cask? || (!args.formula? && !args.multiple? && args.no_named?) - elsif args.manual? || args.auto? + elsif args.installed_on_request? || args.installed_as_dependency? unless args.no_named? raise UsageError, - "Cannot use `--manual` or `--auto` with formula arguments." + "Cannot use `--installed-on-request` or " \ + "`--installed-as-dependency` with formula arguments." end Formula.installed.sort.each do |formula| tab = Tab.for_formula(formula) - if args.manual? && args.auto? - status = tab.installed_on_request ? "manual" : "auto" - puts "#{formula.name}: #{status}" - elsif (args.manual? && tab.installed_on_request) || - (args.auto? && !tab.installed_on_request) + if args.installed_on_request? && args.installed_as_dependency? + statuses = [] + statuses << "installed on request" if tab.installed_on_request + statuses << "installed as dependency" if tab.installed_as_dependency + next if statuses.empty? + + puts "#{formula.name}: #{statuses.join(", ")}" + elsif (args.installed_on_request? && tab.installed_on_request) || + (args.installed_as_dependency? && tab.installed_as_dependency) puts formula.name end end From 4e0c7868b3fbf69c88acf04f501be3ff7794f33d Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Tue, 23 Apr 2024 15:45:24 +0800 Subject: [PATCH 09/12] brew tc --update --- Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/list.rbi | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/list.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/list.rbi index 13734e1e12..1414e477a2 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/list.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/list.rbi @@ -5,9 +5,6 @@ # Please instead update this file by running `bin/tapioca dsl Homebrew::Cmd::List`. class Homebrew::CLI::Args - sig { returns(T::Boolean) } - def auto?; end - sig { returns(T::Boolean) } def cask?; end @@ -32,9 +29,6 @@ class Homebrew::CLI::Args sig { returns(T::Boolean) } def l?; end - sig { returns(T::Boolean) } - def manual?; end - sig { returns(T::Boolean) } def multiple?; end From 107b8c7ca5ab5db865757f5c56ab57cf2aa2f3a6 Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Tue, 23 Apr 2024 15:46:31 +0800 Subject: [PATCH 10/12] test/cmd/list_spec: remove an integration test --- Library/Homebrew/test/cmd/list_spec.rb | 37 -------------------------- 1 file changed, 37 deletions(-) diff --git a/Library/Homebrew/test/cmd/list_spec.rb b/Library/Homebrew/test/cmd/list_spec.rb index 3ca3e9a15a..b5b4a52902 100644 --- a/Library/Homebrew/test/cmd/list_spec.rb +++ b/Library/Homebrew/test/cmd/list_spec.rb @@ -2,24 +2,8 @@ require "cmd/list" require "cmd/shared_examples/args_parse" -require "tab" RSpec.describe Homebrew::Cmd::List do - def setup_installation(formula_name, installed_on_request:) - setup_test_formula(formula_name) - - keg_dir = HOMEBREW_CELLAR/formula_name/"1.0" - keg_dir.mkpath - - tab = Tab.new( - "installed_on_request" => installed_on_request, - "tabfile" => keg_dir/Tab::FILENAME, - ) - tab.write - - keg_dir - end - let(:formulae) { %w[bar foo qux] } it_behaves_like "parseable arguments" @@ -34,25 +18,4 @@ RSpec.describe Homebrew::Cmd::List do .and not_to_output.to_stderr .and be_a_success end - - it "lists the formulae installed on request or automatically", - :integration_test do - setup_installation "foo", installed_on_request: true - setup_installation "bar", installed_on_request: false - - expect { brew "list", "--manual" } - .to be_a_success - .and output("foo\n").to_stdout - .and not_to_output.to_stderr - - expect { brew "list", "--auto" } - .to be_a_success - .and output("bar\n").to_stdout - .and not_to_output.to_stderr - - expect { brew "list", "--manual", "--auto" } - .to be_a_success - .and output("bar: auto\nfoo: manual\n").to_stdout - .and not_to_output.to_stderr - end end From b53998c21f562e3af01ff5674860f6876ba139ce Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Tue, 23 Apr 2024 15:47:36 +0800 Subject: [PATCH 11/12] Fix tapioca compiler args test --- Library/Homebrew/test/sorbet/tapioca/compilers/args_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/test/sorbet/tapioca/compilers/args_spec.rb b/Library/Homebrew/test/sorbet/tapioca/compilers/args_spec.rb index 5e078710b5..c160203735 100644 --- a/Library/Homebrew/test/sorbet/tapioca/compilers/args_spec.rb +++ b/Library/Homebrew/test/sorbet/tapioca/compilers/args_spec.rb @@ -19,9 +19,9 @@ RSpec.describe Tapioca::Compilers::Args do describe "#args_table" do it "returns a mapping of list args to default values" do expect(compiler.args_table(list_parser).keys).to contain_exactly( - :"1?", :auto?, :cask?, :casks?, :d?, :debug?, :formula?, :formulae?, + :"1?", :cask?, :casks?, :d?, :debug?, :formula?, :formulae?, :full_name?, :h?, :help?, :installed_as_dependency?, - :installed_on_request?, :l?, :manual?, :multiple?, :pinned?, + :installed_on_request?, :l?, :multiple?, :pinned?, :q?, :quiet?, :r?, :t?, :v?, :verbose?, :versions? ) end From 00847916167b97a1f996fdb1b9009f3341ff819e Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Tue, 23 Apr 2024 15:49:23 +0800 Subject: [PATCH 12/12] Update manpage and completions --- completions/bash/brew | 8 ++++---- completions/fish/brew.fish | 8 ++++---- completions/zsh/_brew | 24 ++++++++++++------------ docs/Manpage.md | 6 +++--- manpages/brew.1 | 6 +++--- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/completions/bash/brew b/completions/bash/brew index c5827460cf..0112438145 100644 --- a/completions/bash/brew +++ b/completions/bash/brew @@ -1415,13 +1415,13 @@ _brew_list() { case "${cur}" in -*) __brewcomp " - --auto --cask --debug --formula --full-name --help - --manual + --installed-as-dependency + --installed-on-request --multiple --pinned --quiet @@ -1519,13 +1519,13 @@ _brew_ls() { case "${cur}" in -*) __brewcomp " - --auto --cask --debug --formula --full-name --help - --manual + --installed-as-dependency + --installed-on-request --multiple --pinned --quiet diff --git a/completions/fish/brew.fish b/completions/fish/brew.fish index 40fa17825c..256dd77bd8 100644 --- a/completions/fish/brew.fish +++ b/completions/fish/brew.fish @@ -990,13 +990,13 @@ __fish_brew_complete_arg 'linkage' -a '(__fish_brew_suggest_formulae_installed)' __fish_brew_complete_cmd 'list' 'List all installed formulae and casks' -__fish_brew_complete_arg 'list' -l auto -d 'List the formulae installed automatically' __fish_brew_complete_arg 'list' -l cask -d 'List only casks, or treat all named arguments as casks' __fish_brew_complete_arg 'list' -l debug -d 'Display any debugging information' __fish_brew_complete_arg 'list' -l formula -d 'List only formulae, or treat all named arguments as formulae' __fish_brew_complete_arg 'list' -l full-name -d 'Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output' __fish_brew_complete_arg 'list' -l help -d 'Show this message' -__fish_brew_complete_arg 'list' -l manual -d 'List the formulae installed on request' +__fish_brew_complete_arg 'list' -l installed-as-dependency -d 'List the formulae installed as dependencies' +__fish_brew_complete_arg 'list' -l installed-on-request -d 'List the formulae installed on request' __fish_brew_complete_arg 'list' -l multiple -d 'Only show formulae with multiple versions installed' __fish_brew_complete_arg 'list' -l pinned -d 'List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`' __fish_brew_complete_arg 'list' -l quiet -d 'Make some output more quiet' @@ -1058,13 +1058,13 @@ __fish_brew_complete_arg 'log; and not __fish_seen_argument -l formula -l formul __fish_brew_complete_cmd 'ls' 'List all installed formulae and casks' -__fish_brew_complete_arg 'ls' -l auto -d 'List the formulae installed automatically' __fish_brew_complete_arg 'ls' -l cask -d 'List only casks, or treat all named arguments as casks' __fish_brew_complete_arg 'ls' -l debug -d 'Display any debugging information' __fish_brew_complete_arg 'ls' -l formula -d 'List only formulae, or treat all named arguments as formulae' __fish_brew_complete_arg 'ls' -l full-name -d 'Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output' __fish_brew_complete_arg 'ls' -l help -d 'Show this message' -__fish_brew_complete_arg 'ls' -l manual -d 'List the formulae installed on request' +__fish_brew_complete_arg 'ls' -l installed-as-dependency -d 'List the formulae installed as dependencies' +__fish_brew_complete_arg 'ls' -l installed-on-request -d 'List the formulae installed on request' __fish_brew_complete_arg 'ls' -l multiple -d 'Only show formulae with multiple versions installed' __fish_brew_complete_arg 'ls' -l pinned -d 'List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`' __fish_brew_complete_arg 'ls' -l quiet -d 'Make some output more quiet' diff --git a/completions/zsh/_brew b/completions/zsh/_brew index 87b88286b0..81cf7fabfe 100644 --- a/completions/zsh/_brew +++ b/completions/zsh/_brew @@ -1231,16 +1231,16 @@ _brew_linkage() { # brew list _brew_list() { _arguments \ - '(--cask --versions --pinned --full-name)--auto[List the formulae installed automatically]' \ '--debug[Display any debugging information]' \ - '(--versions --pinned --manual --auto --l --r --t)--full-name[Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output]' \ + '(--versions --pinned ---installed-on-request --installed-as-dependency --l --r --t)--full-name[Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output]' \ '--help[Show this message]' \ - '(--cask --versions --pinned --full-name)--manual[List the formulae installed on request]' \ + '(--cask --versions --pinned --full-name)--installed-as-dependency[List the formulae installed as dependencies]' \ + '(--cask --versions --pinned)--installed-on-request[List the formulae installed on request]' \ '(--cask --pinned)--multiple[Only show formulae with multiple versions installed]' \ - '(--cask --multiple --manual --auto --1 --l --r --t --full-name)--pinned[List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`]' \ + '(--cask --multiple --installed-on-request --installed-as-dependency --1 --l --r --t --full-name)--pinned[List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`]' \ '--quiet[Make some output more quiet]' \ '--verbose[Make some output more verbose]' \ - '(--manual --auto --1 --l --r --t --full-name)--versions[Show the version number for installed formulae, or only the specified formulae if formula are provided]' \ + '(--installed-on-request --installed-as-dependency --1 --l --r --t --full-name)--versions[Show the version number for installed formulae, or only the specified formulae if formula are provided]' \ '-1[Force output to be one entry per line. This is the default when output is not to a terminal]' \ '-l[List formulae and/or casks in long format. Has no effect when a formula or cask name is passed as an argument]' \ '-r[Reverse the order of the formulae and/or casks sort to list the oldest entries first. Has no effect when a formula or cask name is passed as an argument]' \ @@ -1249,7 +1249,7 @@ _brew_list() { '(--cask)--formula[List only formulae, or treat all named arguments as formulae]' \ '*::installed_formula:__brew_installed_formulae' \ - installed_cask \ - '(--formula --pinned --multiple --manual --auto)--cask[List only casks, or treat all named arguments as casks]' \ + '(--formula --pinned --multiple --installed-on-request --installed-as-dependency)--cask[List only casks, or treat all named arguments as casks]' \ '*::installed_cask:__brew_installed_casks' } @@ -1314,16 +1314,16 @@ _brew_log() { # brew ls _brew_ls() { _arguments \ - '(--cask --versions --pinned --full-name)--auto[List the formulae installed automatically]' \ '--debug[Display any debugging information]' \ - '(--versions --pinned --manual --auto --l --r --t)--full-name[Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output]' \ + '(--versions --pinned ---installed-on-request --installed-as-dependency --l --r --t)--full-name[Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output]' \ '--help[Show this message]' \ - '(--cask --versions --pinned --full-name)--manual[List the formulae installed on request]' \ + '(--cask --versions --pinned --full-name)--installed-as-dependency[List the formulae installed as dependencies]' \ + '(--cask --versions --pinned)--installed-on-request[List the formulae installed on request]' \ '(--cask --pinned)--multiple[Only show formulae with multiple versions installed]' \ - '(--cask --multiple --manual --auto --1 --l --r --t --full-name)--pinned[List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`]' \ + '(--cask --multiple --installed-on-request --installed-as-dependency --1 --l --r --t --full-name)--pinned[List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`]' \ '--quiet[Make some output more quiet]' \ '--verbose[Make some output more verbose]' \ - '(--manual --auto --1 --l --r --t --full-name)--versions[Show the version number for installed formulae, or only the specified formulae if formula are provided]' \ + '(--installed-on-request --installed-as-dependency --1 --l --r --t --full-name)--versions[Show the version number for installed formulae, or only the specified formulae if formula are provided]' \ '-1[Force output to be one entry per line. This is the default when output is not to a terminal]' \ '-l[List formulae and/or casks in long format. Has no effect when a formula or cask name is passed as an argument]' \ '-r[Reverse the order of the formulae and/or casks sort to list the oldest entries first. Has no effect when a formula or cask name is passed as an argument]' \ @@ -1332,7 +1332,7 @@ _brew_ls() { '(--cask)--formula[List only formulae, or treat all named arguments as formulae]' \ '*::installed_formula:__brew_installed_formulae' \ - installed_cask \ - '(--formula --pinned --multiple --manual --auto)--cask[List only casks, or treat all named arguments as casks]' \ + '(--formula --pinned --multiple --installed-on-request --installed-as-dependency)--cask[List only casks, or treat all named arguments as casks]' \ '*::installed_cask:__brew_installed_casks' } diff --git a/docs/Manpage.md b/docs/Manpage.md index 6f6da800a0..b23527c6a1 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -741,13 +741,13 @@ paths within its current keg. If *`cask`* is provided, list its artifacts. : List only pinned formulae, or only the specified (pinned) formulae if *`formula`* are provided. See also `pin`, `unpin`. -`--manual` +`--installed-on-request` : List the formulae installed on request. -`--auto` +`--installed-as-dependency` -: List the formulae installed automatically. +: List the formulae installed as dependencies. `-1` diff --git a/manpages/brew.1 b/manpages/brew.1 index 9c891eb639..736a3cda9d 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -464,11 +464,11 @@ Only show formulae with multiple versions installed\. \fB\-\-pinned\fP List only pinned formulae, or only the specified (pinned) formulae if \fIformula\fP are provided\. See also \fBpin\fP, \fBunpin\fP\&\. .TP -\fB\-\-manual\fP +\fB\-\-installed\-on\-request\fP List the formulae installed on request\. .TP -\fB\-\-auto\fP -List the formulae installed automatically\. +\fB\-\-installed\-as\-dependency\fP +List the formulae installed as dependencies\. .TP \fB\-1\fP Force output to be one entry per line\. This is the default when output is not to a terminal\.