Only brew desc --search
needs --eval-all
- It was suggested in https://github.com/Homebrew/brew/issues/ 16733 that `brew desc <formula_or_cask>` should work like `brew info <formula_or_cask>` and print the description of the package without needing `--eval-all`. - Looking at the code, it seems like it's only searching that needs `--eval-all`, so limit the check to that. Before: ```shell $ brew desc hello Error: `brew desc` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL` set! ``` After: ```shell $ brew desc hello hello: Program providing model for GNU coding standards and practices $ brew desc --search hello Error: Invalid usage: `brew desc --search` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL` set! $ brew desc --search --eval-all hello ==> Formulae dsh: Dancer's shell, or distributed shell hello: Program providing model for GNU coding standards and practices ```
This commit is contained in:
parent
929995c810
commit
69c31d275f
@ -38,10 +38,6 @@ module Homebrew
|
||||
|
||||
sig { override.void }
|
||||
def run
|
||||
if !args.eval_all? && !Homebrew::EnvConfig.eval_all?
|
||||
raise UsageError, "`brew desc` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL` set!"
|
||||
end
|
||||
|
||||
search_type = if args.search?
|
||||
:either
|
||||
elsif args.name?
|
||||
@ -50,7 +46,16 @@ module Homebrew
|
||||
:desc
|
||||
end
|
||||
|
||||
if search_type.blank?
|
||||
if search_type.present?
|
||||
if !args.eval_all? && !Homebrew::EnvConfig.eval_all?
|
||||
raise UsageError, "`brew desc --search` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL` set!"
|
||||
end
|
||||
|
||||
query = args.named.join(" ")
|
||||
string_or_regex = Search.query_regexp(query)
|
||||
return Search.search_descriptions(string_or_regex, args, search_type:)
|
||||
end
|
||||
|
||||
desc = {}
|
||||
args.named.to_formulae_and_casks.each do |formula_or_cask|
|
||||
case formula_or_cask
|
||||
@ -64,11 +69,6 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
Descriptions.new(desc).print
|
||||
else
|
||||
query = args.named.join(" ")
|
||||
string_or_regex = Search.query_regexp(query)
|
||||
Search.search_descriptions(string_or_regex, args, search_type:)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -9,9 +9,25 @@ RSpec.describe Homebrew::Cmd::Desc do
|
||||
it "shows a given Formula's description", :integration_test do
|
||||
setup_test_formula "testball"
|
||||
|
||||
expect { brew "desc", "--eval-all", "testball" }
|
||||
expect { brew "desc", "testball" }
|
||||
.to output("testball: Some test\n").to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
it "errors when searching without --eval-all", :integration_test do
|
||||
setup_test_formula "testball"
|
||||
|
||||
expect { brew "desc", "--search", "testball" }
|
||||
.to output(/`brew desc --search` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL` set!/).to_stderr
|
||||
.and be_a_failure
|
||||
end
|
||||
|
||||
it "successfully searches with --search --eval-all", :integration_test do
|
||||
setup_test_formula "testball"
|
||||
|
||||
expect { brew "desc", "--search", "--eval-all", "ball" }
|
||||
.to output(/testball: Some test/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user