Class: ConfigKit::Cli::Init

Inherits:
Command
  • Object
show all
Defined in:
lib/config_kit/cli/commands/init.rb

Instance Attribute Summary

Attributes inherited from Command

#leftover

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

inherited, run

Constructor Details

#initialize(args) ⇒ Init

Returns a new instance of Init.



5
6
7
8
# File 'lib/config_kit/cli/commands/init.rb', line 5

def initialize(args)
  @output
  super(args)
end

Class Method Details

.commandObject



3
# File 'lib/config_kit/cli/commands/init.rb', line 3

def self.command; "init"; end

Instance Method Details

#runObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/config_kit/cli/commands/init.rb', line 10

def run
  begin
    raise ConfigKit::Cli::Command::CommandFailure.new 'Missing name options' if @name.nil?
    raise ConfigKit::Cli::Command::CommandFailure.new 'Missing environment options' if @env.nil?
    @output = ConfigKit::Manager.init(@name, @env, @codename)
    pp @output.to_h.to_json
  rescue ConfigKit::Cli::Command::CommandFailure
    raise
  rescue => e
    ConfigKit.logger.error "Unexpected error attempting to get config data #{@uri} in env #{@env} for #{@app.nil? ? 'all' : @app}"
    ConfigKit.logger.debug "#{e}: #{e.backtrace.join("\n   ")}"
    raise ConfigKit::Cli::Command::CommandFailure.new(e.to_s)
  end
end