44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/cnvrg/cli.rb', line 44
def initialize(args = [], local_options = {}, config = {})
parse_options = Thor.class_options
command_options = config.delete(:command_options) parse_options = parse_options.merge(command_options) if command_options
if local_options.is_a?(Array)
array_options = local_options
hash_options = {}
else
array_options = []
hash_options = local_options
end
stop_on_unknown = Thor.stop_on_unknown_option? config[:current_command]
opts = Thor::Options.new(parse_options, hash_options, stop_on_unknown)
real_options = []
real_args = [].replace(array_options)
if local_options.is_a? (Array) and !local_options.empty? and args.empty?
array_options.each_with_index do |p, i|
opt = p
if p.include? "="
opt = p.split("=")[0]
end
option = is_option(parse_options.values, opt)
if !option
break
else
real_options << p
real_args.delete(p)
if !p.include? "=" and option.type != :boolean
if i + 1 < array_options.size
real_options << array_options[i + 1]
real_args.delete(array_options[i + 1])
end
end
end
end
args = real_args
else
if !args.empty? and local_options.is_a? Array and !local_options.empty?
args = args + local_options
else
args = args.flatten()
end
end
self.options = opts.parse(real_options)
self.options = config[:class_options].merge(options) if config[:class_options]
opts.check_unknown! if Thor.check_unknown_options?(config)
to_parse = args
to_parse += opts.remaining unless self.class.strict_args_position?(config)
thor_args = Thor::Arguments.new(self.class.arguments)
thor_args.parse(to_parse).each {|k, v| __send__("#{k}=", v)}
@args = thor_args.remaining
end
|