Class: Sfn::Command::Conf
- Inherits:
-
Sfn::Command
- Object
- Bogo::Cli::Command
- Sfn::Command
- Sfn::Command::Conf
- Defined in:
- lib/sfn/command/conf.rb
Overview
Config command
Constant Summary collapse
- SFN_CONFIG_CONTENTS =
<<-EOF # This is an auto-generated configuration file for # the sfn CLI. To view all available configuration # options, please see: # http://www.sparkleformation.io/docs/sfn/configuration.html Configuration.new do apply_nesting 'deep' processing true options do on_failure 'nothing' notification_topics [] capabilities ['CAPABILITY_IAM'] tags do creator ENV['USER'] end end # nesting_bucket 'BUCKET_NAME' credentials do provider :aws aws_access_key_id ENV['AWS_ACCESS_KEY_ID'] aws_secret_access_key ENV['AWS_SECRET_ACCESS_KEY'] aws_region ENV['AWS_REGION'] aws_bucket_region ENV['AWS_REGION'] # aws_sts_role_arn ENV['AWS_STS_ROLE_ARN'] end end EOF
Instance Method Summary collapse
-
#execute! ⇒ Object
Run the list command.
- #format_value(value, indent = '') ⇒ Object
- #generate_config! ⇒ Object
Methods inherited from Sfn::Command
Methods included from Sfn::CommandModule::Callbacks
#api_action!, #callbacks_for, #run_callbacks_for
Constructor Details
This class inherits a constructor from Sfn::Command
Instance Method Details
#execute! ⇒ Object
Run the list command
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sfn/command/conf.rb', line 9 def execute! ui.info ui.color("Current configuration state:") Config::Conf.attributes.sort_by(&:first).each do |k, val| if(config.has_key?(k)) ui.print " #{ui.color(k, :bold, :green)}: " format_value(config[k], ' ') end end 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 |
#format_value(value, indent = '') ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/sfn/command/conf.rb', line 38 def format_value(value, indent='') if(value.is_a?(Hash)) ui.puts 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)) ui.puts value.map(&:to_s).sort.each do |v| ui.print "#{indent} " format_value(v, indent + ' ') end else ui.puts value.to_s end end |
#generate_config! ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sfn/command/conf.rb', line 25 def generate_config! 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| file.write SFN_CONFIG_CONTENTS end nil end end |