Merge pull request #12234 from ni-nwoythaler/feature/12230-formula-cask-paths
Add `--print-path` flag to `brew edit`
This commit is contained in:
commit
144ca4ef61
@ -299,6 +299,9 @@ module Homebrew
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def custom_remote?; end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def print_path?; end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -186,10 +186,6 @@ module Homebrew
|
||||
to_formulae_to_casks(only: only, method: :resolve)
|
||||
end
|
||||
|
||||
def to_formulae_paths
|
||||
to_paths(only: :formula)
|
||||
end
|
||||
|
||||
# Keep existing paths and try to convert others to tap, formula or cask paths.
|
||||
# If a cask and formula with the same name exist, includes both their paths
|
||||
# unless `only` is specified.
|
||||
|
||||
@ -21,6 +21,8 @@ module Homebrew
|
||||
description: "Treat all named arguments as formulae."
|
||||
switch "--cask", "--casks",
|
||||
description: "Treat all named arguments as casks."
|
||||
switch "--print-path",
|
||||
description: "Print the file path to be edited, without opening an editor."
|
||||
|
||||
conflicts "--formula", "--cask"
|
||||
|
||||
@ -59,6 +61,11 @@ module Homebrew
|
||||
end.presence
|
||||
end
|
||||
|
||||
if args.print_path?
|
||||
paths.each(&method(:puts))
|
||||
return
|
||||
end
|
||||
|
||||
exec_editor(*paths)
|
||||
end
|
||||
end
|
||||
|
||||
@ -23,6 +23,13 @@ module Homebrew
|
||||
def formula
|
||||
args = formula_args.parse
|
||||
|
||||
args.named.to_formulae_paths.each(&method(:puts))
|
||||
formula_paths = args.named.to_paths(only: :formula).select(&:exist?)
|
||||
if formula_paths.blank? && args.named
|
||||
.to_paths(only: :cask)
|
||||
.select(&:exist?)
|
||||
.present?
|
||||
odie "Found casks but did not find formulae!"
|
||||
end
|
||||
formula_paths.each(&method(:puts))
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user