Refactor CLI#option_parser
This commit is contained in:
parent
86e745a3a6
commit
ac8b115d0f
@ -93,23 +93,20 @@ module Producer
|
|||||||
opts.separator ''
|
opts.separator ''
|
||||||
opts.separator 'options:'
|
opts.separator 'options:'
|
||||||
|
|
||||||
opts.on '-v', '--verbose', 'enable verbose mode' do
|
option_parser_add_boolean_options opts
|
||||||
env.verbose = true
|
|
||||||
end
|
|
||||||
|
|
||||||
opts.on '-d', '--debug', 'enable debug mode' do
|
|
||||||
env.debug = true
|
|
||||||
end
|
|
||||||
|
|
||||||
opts.on '-n', '--dry-run', 'enable dry run mode' do
|
|
||||||
env.dry_run = true
|
|
||||||
end
|
|
||||||
|
|
||||||
opts.on '-t', '--target HOST', 'target host' do |e|
|
opts.on '-t', '--target HOST', 'target host' do |e|
|
||||||
env.target = e
|
env.target = e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def option_parser_add_boolean_options(opts)
|
||||||
|
{ v: 'verbose', d: 'debug', n: 'dry run' }.each do |k, v|
|
||||||
|
opts.on "-#{k}", "--#{v.tr ' ', '-'}", "enable #{v} mode" do
|
||||||
|
env.send "#{v.tr ' ', '_'}=", true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user