Class: Gitlab::CLI
- Inherits:
-
Object
- Object
- Gitlab::CLI
- Extended by:
- Helpers
- Defined in:
- lib/gitlab/cli.rb,
lib/gitlab/cli_helpers.rb
Defined Under Namespace
Modules: Helpers
Class Method Summary collapse
Methods included from Helpers
actions_table, confirm_command, excluded_fields, gitlab_helper, multiple_record_table, output_table, required_fields, single_record_table, symbolize_keys, valid_command?, yaml_load_and_symbolize_hash!
Class Method Details
.run(cmd, args = []) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/gitlab/cli.rb', line 14 def self.run(cmd, args=[]) case cmd when 'help' puts actions_table when 'info' endpoint = Gitlab.endpoint ? Gitlab.endpoint : 'not set' private_token = Gitlab.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' puts "Gitlab Ruby Gem #{Gitlab::VERSION}" when 'shell' Gitlab::Shell.start else 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=')) command_args = args[0..-2] else command_args = args end begin yaml_load_and_symbolize_hash!(command_args) rescue exit 1 end confirm_command(cmd) data = gitlab_helper(cmd, command_args) { exit(1) } output_table(cmd, args, data) end end |
.start(args) ⇒ Object
9 10 11 12 |
# File 'lib/gitlab/cli.rb', line 9 def self.start(args) command = args.shift.strip rescue 'help' run(command, args) end |