mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
edit: Use Parser to parse args
This commit is contained in:
parent
2ec684a123
commit
56fb2cb67c
@ -5,11 +5,16 @@
|
|||||||
#: Open <formula> in the editor.
|
#: Open <formula> in the editor.
|
||||||
|
|
||||||
require "formula"
|
require "formula"
|
||||||
|
require "cli_parser"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
args = Homebrew::CLI::Parser.new do
|
||||||
|
switch "--force"
|
||||||
|
end.parse
|
||||||
|
|
||||||
unless (HOMEBREW_REPOSITORY/".git").directory?
|
unless (HOMEBREW_REPOSITORY/".git").directory?
|
||||||
raise <<~EOS
|
raise <<~EOS
|
||||||
Changes will be lost!
|
Changes will be lost!
|
||||||
@ -36,7 +41,7 @@ module Homebrew
|
|||||||
paths = ARGV.named.map do |name|
|
paths = ARGV.named.map do |name|
|
||||||
path = Formulary.path(name)
|
path = Formulary.path(name)
|
||||||
|
|
||||||
raise FormulaUnavailableError, name unless path.file? || ARGV.force?
|
raise FormulaUnavailableError, name unless path.file? || args.force?
|
||||||
|
|
||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user