Class: ConfigKit::Cli::Bootstrap
- Defined in:
- lib/config_kit/cli/commands/bootstrap.rb
Instance Attribute Summary
Attributes inherited from Command
Class Method Summary collapse
Instance Method Summary collapse
- #check_args ⇒ Object
-
#initialize(args) ⇒ Bootstrap
constructor
A new instance of Bootstrap.
- #run ⇒ Object
Methods inherited from Command
Constructor Details
#initialize(args) ⇒ Bootstrap
Returns a new instance of Bootstrap.
10 11 12 13 14 15 16 |
# File 'lib/config_kit/cli/commands/bootstrap.rb', line 10 def initialize(args) @uri_string = 'file:///./config' @app = 'all' super(args) @uri_kls = self.class.uri_parser(@uri_string) check_args end |
Class Method Details
.command ⇒ Object
8 |
# File 'lib/config_kit/cli/commands/bootstrap.rb', line 8 def self.command; "bootstrap"; end |
.uri_parser(uri) ⇒ Object
4 5 6 |
# File 'lib/config_kit/cli/commands/bootstrap.rb', line 4 def self.uri_parser(uri) URI.parse(uri) end |
Instance Method Details
#check_args ⇒ Object
18 19 20 21 22 23 |
# File 'lib/config_kit/cli/commands/bootstrap.rb', line 18 def check_args raise ConfigKit::Cli::Command::CommandFailure.new "Wrong bootstrap source from #{@from}, pls use file or git" unless ['git', 'file'].include?(@from) raise ConfigKit::Cli::Command::CommandFailure.new "Missmatch source from #{@from} and uri #{@uri_string}" if @from == 'file' && @uri_kls.scheme != 'file' raise ConfigKit::Cli::Command::CommandFailure.new "Missmatch source from #{@from} and uri #{@uri_string}" if @from == 'git' && !['git', 'http', 'ssh'].include?(@uri_kls.scheme) raise ConfigKit::Cli::Command::CommandFailure.new "Missmatch tag from #{@from} and uri #{@uri_string}" if @from == 'git' && @tag.nil? end |
#run ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/config_kit/cli/commands/bootstrap.rb', line 25 def run begin @output = ConfigKit::Manager.bootstrap(@app, @from, @uri_kls, @tag, {}) pp @output.to_h.to_json rescue => e ConfigKit.logger.error "Unexpected error attempting to get config data #{@uri_string} in for #{@app.nil? ? 'all' : @app}" ConfigKit.logger.debug "#{e}: #{e.backtrace.join("\n ")}" raise ConfigKit::Cli::Command::CommandFailure.new(e.to_s) end end |