lib/gitlab/cli.rb in gitlab-3.1.0 vs lib/gitlab/cli.rb in gitlab-3.2.0

- old
+ new

@@ -1,8 +1,9 @@ require 'gitlab' require 'terminal-table/import' require_relative 'cli_helpers' +require_relative 'shell' class Gitlab::CLI extend Helpers def self.start(args) @@ -21,12 +22,14 @@ puts "Gitlab private token is #{private_token}" puts "Ruby Version is #{RUBY_VERSION}" puts "Gitlab Ruby Gem #{Gitlab::VERSION}" when '-v', '--version' puts "Gitlab Ruby Gem #{Gitlab::VERSION}" + when 'shell' + Gitlab::Shell.start else - unless Gitlab.actions.include?(cmd.to_sym) + unless valid_command?(cmd) puts "Unknown command. Run `gitlab help` for a list of available commands." exit(1) end if args.any? && (args.last.start_with?('--only=') || args.last.start_with?('--except=')) @@ -35,23 +38,10 @@ command_args = args end confirm_command(cmd) - begin - data = args.any? ? Gitlab.send(cmd, *command_args) : Gitlab.send(cmd) - rescue => e - puts e.message - exit(1) - end - - case data - when Gitlab::ObjectifiedHash - puts single_record_table(data, cmd, args) - when Array - puts multiple_record_table(data, cmd, args) - else - puts data.inspect - end + data = gitlab_helper(cmd, command_args) { exit(1) } + output_table(cmd, args, data) end end end