lib/awskeyring_command.rb in awskeyring-1.6.0 vs lib/awskeyring_command.rb in awskeyring-1.7.0

- old
+ new

@@ -385,10 +385,11 @@ puts I18n.t('message.addtoken', account: account, time: Time.at(new_creds[:expiry].to_i)) end desc 'console ACCOUNT', I18n.t('console.desc') method_option :path, type: :string, aliases: '-p', desc: I18n.t('method_option.path') + method_option :browser, type: :string, aliases: '-b', desc: I18n.t('method_option.browser') method_option 'no-token', type: :boolean, aliases: '-n', desc: I18n.t('method_option.notoken'), default: false method_option 'no-open', type: :boolean, aliases: '-o', desc: I18n.t('method_option.noopen'), default: false # Open the AWS Console def console(account = nil) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength account = ask_check( @@ -415,11 +416,12 @@ end if options['no-open'] puts login_url else - pid = Process.spawn("open \"#{login_url}\"") + spawn_cmd = options[:browser] ? "open -a \"#{options[:browser]}\" \"#{login_url}\"" : "open \"#{login_url}\"" + pid = Process.spawn(spawn_cmd) Process.wait pid end end desc 'awskeyring CURR PREV', I18n.t('awskeyring.desc'), hide: true @@ -458,13 +460,15 @@ when 'help', File.basename($PROGRAM_NAME) comp_len = 0 when 'remove-role', '-r', 'rmr' comp_len = 2 when '--path', '-p' - comp_len = 4 + comp_len = 40 when 'remove-token', 'rmt' - comp_len = 5 + comp_len = 50 + when '--browser', '-b' + comp_len = 60 end [curr, comp_len, sub_cmd] end @@ -485,15 +489,17 @@ list = list_commands when 1 list = Awskeyring.list_account_names when 2 list = Awskeyring.list_role_names - when 3 + when 3..10 list = list_arguments(command: sub_cmd) - when 4 + when 40 list = Awskeyring.list_console_path - when 5 + when 50 list = Awskeyring.list_token_names + when 60 + list = Awskeyring.list_browsers else exit 1 end puts list.select { |elem| elem.start_with?(curr) }.sort!.join("\n") end