Method: Beaker::Subcommand#init

Defined in:
lib/beaker/subcommand.rb

#initObject



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
# File 'lib/beaker/subcommand.rb', line 77

def init()
  if options[:help]
    invoke :help, [], ["init"]
    return
  end

  @cli.parse_options

  # delete unnecessary keys for saving the options
  options_to_write = @cli.configured_options
  # Remove keys we don't want to save
  [:timestamp, :logger, :command_line, :beaker_version, :hosts_file].each do |key|
    options_to_write.delete(key)
  end

  options_to_write = SubcommandUtil.sanitize_options_for_save(options_to_write)

  @cli.logger.notify 'Writing configured options to disk'
  File.open(SubcommandUtil::SUBCOMMAND_OPTIONS, 'w') do |f|
    f.write(options_to_write.to_yaml)
  end
  @cli.logger.notify "Options written to #{SubcommandUtil::SUBCOMMAND_OPTIONS}"

  state = YAML::Store.new(SubcommandUtil::SUBCOMMAND_STATE)
  state.transaction do
    state['provisioned'] = false
  end
end