cmd, dev-cmd: use args.formulae_paths.

This makes these commands robust to invalid syntax.
This commit is contained in:
Mike McQuaid 2020-04-14 14:21:17 +01:00
parent 5366da76fd
commit 4fb649cad1
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
5 changed files with 7 additions and 14 deletions

View File

@ -25,6 +25,6 @@ module Homebrew
else
"cat"
end
safe_system pager, args.formulae.first.path, *args.passthrough
safe_system pager, args.formulae_paths.first, *args.passthrough
end
end

View File

@ -45,7 +45,7 @@ module Homebrew
elsif args.named.any? { |tap| tap.count("/") == 1 }
args.named.map { |tap| Tap.fetch(tap).path }
else
args.formulae.map(&:path)
args.formulae_paths
end
only_cops = args.only_cops

View File

@ -84,7 +84,7 @@ module Homebrew
files = Tap.map(&:formula_dir)
else
ff = args.resolved_formulae
files = args.resolved_formulae.map(&:path)
files = args.formulae_paths
end
only_cops = args.only_cops

View File

@ -14,7 +14,6 @@ module Homebrew
Open <formula> in the editor set by `EDITOR` or `HOMEBREW_EDITOR`, or open the
Homebrew repository for editing if no formula is provided.
EOS
switch :force
switch :verbose
switch :debug
end
@ -31,16 +30,10 @@ module Homebrew
EOS
end
paths = args.formulae_paths.presence
# If no brews are listed, open the project root in an editor.
paths = [HOMEBREW_REPOSITORY] if args.no_named?
# Don't use args.formulae as that will throw if the file doesn't parse
paths ||= args.named.map do |name|
path = Formulary.path(name)
raise FormulaUnavailableError, name if !path.file? && !args.force?
path
end
paths ||= [HOMEBREW_REPOSITORY]
exec_editor(*paths)
end

View File

@ -22,6 +22,6 @@ module Homebrew
def formula
formula_args.parse
args.resolved_formulae.each { |f| puts f.path }
args.formulae_paths.each(&method(:puts))
end
end