Class: Awshucks::NewConfigCommand
- Defined in:
- lib/awshucks/commands/new_config.rb
Instance Method Summary collapse
-
#execute(args, config) ⇒ Object
def custom_options(opts) opts.on(‘-f’, ‘–force’, “Overwrite the existing config file if it exists”) do parsed_options.overwrite = true end end.
Methods inherited from Command
commands, execute, inherited, #option_parser, option_string, parse_and_execute
Instance Method Details
#execute(args, config) ⇒ Object
def custom_options(opts)
opts.on('-f', '--force', "Overwrite the existing config file if it exists") do
.overwrite = true
end
end
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/awshucks/commands/new_config.rb', line 14 def execute(args, config) # option_parser.parse!(args) dest_path = File.(args.empty? ? 'awshucks.yml' : args.first) if File.exists?(dest_path)# && !parsed_options.overwrite $stderr.puts "cannot create #{dest_path}, file already exists" else puts "creating new config file at #{dest_path}" FileUtils.cp(awshucks_config, dest_path ) end end |