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) }
|
sig { returns(T::Boolean) }
|
||||||
def custom_remote?; end
|
def custom_remote?; end
|
||||||
|
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
|
def print_path?; end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -186,10 +186,6 @@ module Homebrew
|
|||||||
to_formulae_to_casks(only: only, method: :resolve)
|
to_formulae_to_casks(only: only, method: :resolve)
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_formulae_paths
|
|
||||||
to_paths(only: :formula)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Keep existing paths and try to convert others to tap, formula or cask paths.
|
# 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
|
# If a cask and formula with the same name exist, includes both their paths
|
||||||
# unless `only` is specified.
|
# unless `only` is specified.
|
||||||
|
|||||||
@ -21,6 +21,8 @@ module Homebrew
|
|||||||
description: "Treat all named arguments as formulae."
|
description: "Treat all named arguments as formulae."
|
||||||
switch "--cask", "--casks",
|
switch "--cask", "--casks",
|
||||||
description: "Treat all named arguments as 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"
|
conflicts "--formula", "--cask"
|
||||||
|
|
||||||
@ -59,6 +61,11 @@ module Homebrew
|
|||||||
end.presence
|
end.presence
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if args.print_path?
|
||||||
|
paths.each(&method(:puts))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
exec_editor(*paths)
|
exec_editor(*paths)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -23,6 +23,13 @@ module Homebrew
|
|||||||
def formula
|
def formula
|
||||||
args = formula_args.parse
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user