lib/gitlab/cli.rb in gitlab-4.5.0 vs lib/gitlab/cli.rb in gitlab-4.6.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'gitlab' require 'terminal-table/import' require_relative 'cli_helpers' require_relative 'shell' @@ -15,11 +17,15 @@ # Gitlab::CLI.start(['help']) # Gitlab::CLI.start(['help', 'issues']) # # @param [Array] args The command and it's optional arguments. def self.start(args) - command = args.shift.strip rescue 'help' + command = begin + args.shift.strip + rescue StandardError + 'help' + end run(command, args) end # Processes a CLI command and outputs a result to the stream (stdout). # @@ -28,17 +34,17 @@ # Gitlab::CLI.run('help', ['issues']) # # @param [String] cmd The name of a command. # @param [Array] args The optional arguments for a command. # @return [nil] - def self.run(cmd, args=[]) + def self.run(cmd, args = []) case cmd when 'help' puts help(args.shift) { |out| out.gsub!(/Gitlab\./, 'gitlab ') } when 'info' - endpoint = Gitlab.endpoint ? Gitlab.endpoint : 'not set' - private_token = Gitlab.private_token ? Gitlab.private_token : 'not set' + endpoint = Gitlab.endpoint || 'not set' + private_token = Gitlab.private_token || 'not set' puts "Gitlab endpoint is #{endpoint}" puts "Gitlab private token is #{private_token}" puts "Ruby Version is #{RUBY_VERSION}" puts "Gitlab Ruby Gem #{Gitlab::VERSION}" when '-v', '--version' @@ -58,10 +64,10 @@ command_args = args.any? && args.last.start_with?('--only=', '--except=') ? args[0..-2] : args begin command_args.map! { |arg| symbolize_keys(yaml_load(arg)) } - rescue => e + rescue StandardError => e puts e.message exit 1 end confirm_command(cmd)