lib/sfn/command/conf.rb in sfn-3.0.28 vs lib/sfn/command/conf.rb in sfn-3.0.30

- old
+ new

@@ -2,32 +2,31 @@ module Sfn class Command # Config command class Conf < Command - include Sfn::CommandModule::Base # Run the list command def execute! ui.info ui.color("Current configuration state:") Config::Conf.attributes.sort_by(&:first).each do |k, val| - if(config.has_key?(k)) + if config.has_key?(k) ui.print " #{ui.color(k, :bold, :green)}: " format_value(config[k], ' ') end end - if(config[:generate]) + if config[:generate] ui.puts ui.info 'Generating .sfn configuration file..' generate_config! ui.info "Generation of .sfn configuration file #{ui.color('complete!', :green, :bold)}" end end def generate_config! - if(File.exists?('.sfn')) + if File.exists?('.sfn') ui.warn 'Existing .sfn configuration file detected!' ui.confirm 'Overwrite current .sfn configuration file?' end run_action 'Writing .sfn file' do File.open('.sfn', 'w') do |file| @@ -35,18 +34,18 @@ end nil end end - def format_value(value, indent='') - if(value.is_a?(Hash)) + def format_value(value, indent = '') + if value.is_a?(Hash) ui.puts - value.sort_by(&:first).each do |k,v| + value.sort_by(&:first).each do |k, v| ui.print "#{indent} #{ui.color(k, :bold)}: " format_value(v, indent + ' ') end - elsif(value.is_a?(Array)) + elsif value.is_a?(Array) ui.puts value.map(&:to_s).sort.each do |v| ui.print "#{indent} " format_value(v, indent + ' ') end @@ -132,10 +131,8 @@ terraform_local_directory './terraform-stacks' terraform_local_scrub_destroyed false end end EOF - - end end end