lib/meroku/cli.rb in meroku-2.0.24 vs lib/meroku/cli.rb in meroku-2.0.25

- old
+ new

@@ -3,20 +3,18 @@ module Meroku # The CLI is a class responsible of handling all the command line interface # logic. class CLI include Meroku::Shared - include Meroku::Api attr_reader :options def initialize @options = {} end def run(args = ARGV) @options = Options.new.parse(args) - act_on_user_options act_on_options rescue Meroku::Success return 0 rescue StandardError => e print 'Error:' @@ -26,15 +24,34 @@ end private def act_on_options - if @options[:meroku_secret] - Meroku::Shared.secrets.meroku_secret = @options[:meroku_secret] - end + act_on_key_options + act_on_app_options + act_on_user_options + act_on_misc_options + true + end + + def act_on_app_options + App.create(@options[:name]) if @options[:create] + App.list_apps if @options[:list_apps] + App.delete_app(@options[:name]) if @options[:delete_app] + end + + def act_on_key_options + Key.upload if @options[:keys_add] + Key.list if @options[:keys] + Key.remove(@options[:key_id]) if @options[:keys_remove] + end + + def act_on_misc_options + Meroku::Shared.secrets.meroku_secret = @options[:meroku_secret] \ + if @options[:meroku_secret] + Node.new if @options[:spawn] Meroku::Aws.terminate_all(tag: 'node') if @options[:despawn] - true end def act_on_user_options User.login(@options[:email], @options[:password]) if @options[:login] User.logout if @options[:logout]