cli/args: simplify initialisation.
Move some logic from `CLI::Parser` to `CLI::Args` to simplify and make more consistent the initialisation process.
This commit is contained in:
parent
b05c72b98b
commit
8d868b739c
@ -9,10 +9,12 @@ module Homebrew
|
||||
# undefine tap to allow --tap argument
|
||||
undef tap
|
||||
|
||||
def initialize(argv:)
|
||||
def initialize
|
||||
super
|
||||
@argv = argv
|
||||
@cmdline_args = argv
|
||||
|
||||
self[:remaining] = []
|
||||
self[:cmdline_args] = ARGV_WITHOUT_MONKEY_PATCHING.dup
|
||||
|
||||
@args_parsed = false
|
||||
@processed_options = []
|
||||
end
|
||||
@ -60,8 +62,6 @@ module Homebrew
|
||||
end
|
||||
|
||||
def named
|
||||
return [] if remaining.nil?
|
||||
|
||||
remaining
|
||||
end
|
||||
|
||||
|
@ -37,11 +37,10 @@ module Homebrew
|
||||
}
|
||||
end
|
||||
|
||||
def initialize(args = ARGV, &block)
|
||||
def initialize(&block)
|
||||
@parser = OptionParser.new
|
||||
@args = Homebrew::CLI::Args.new(argv: ARGV_WITHOUT_MONKEY_PATCHING)
|
||||
@args[:remaining] = []
|
||||
@args[:cmdline_args] = args.dup
|
||||
@args = Homebrew::CLI::Args.new
|
||||
|
||||
@constraints = []
|
||||
@conflicts = []
|
||||
@switch_sources = {}
|
||||
|
@ -86,7 +86,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
def args
|
||||
@args ||= CLI::Args.new(argv: ARGV_WITHOUT_MONKEY_PATCHING)
|
||||
@args ||= CLI::Args.new
|
||||
end
|
||||
|
||||
def messages
|
||||
|
Loading…
x
Reference in New Issue
Block a user