lib/gl/cli.rb in gl-0.1.0 vs lib/gl/cli.rb in gl-0.2.0
- old
+ new
@@ -4,41 +4,34 @@
require 'gl/cli/merge_requests'
require 'gl/cli/issues'
module Gl
class CLI < Thor
- desc 'registry', 'registry'
+ desc 'registry', 'handle registry of the project'
subcommand 'registry', Registry
- desc 'mr', 'merge requests'
+ desc 'mr', 'handle merge requests of the project'
subcommand 'mr', MergeRequests
- desc 'issues', 'issues'
+ desc 'issues', 'handle issues of the project'
subcommand 'issues', Issues
def self.setup
+ Gitlab.endpoint = "https://#{Gl.remote_base}/api/v4/"
+
prompt = TTY::Prompt.new
- endpoint = `git config --get gitlab.endpoint`.chomp
- if endpoint.empty?
- endpoint = prompt.ask('Please enter the GitLab endpoint', default: 'https://gitlab.com')
- endpoint = "#{endpoint}/api/v4"
-
- if prompt.yes?("Do you want to persist #{endpoint} as gitlab.endpoint to your git config")
- `git config --global --add gitlab.endpoint #{endpoint}`
- end
- end
-
- token = `git config --get gitlab.token`.chomp
+ token = `git config --get gl.#{Gl.remote_slug}.token`.chomp
if token.empty?
- token = prompt.mask('Please enter your GitLab token')
+ Gl.open_in_browser('profile/personal_access_tokens')
+ token = prompt.mask("Please enter your GitLab token for #{Gl.remote_base}")
- if prompt.yes?('Do you want to persist the tokee as gitlab.token to your git config')
- `git config --global --add gitlab.token #{token}`
+ token_name = "gl.#{Gl.remote_slug}.token"
+ if prompt.yes?("Do you want to persist the token as #{token_name} to your git config")
+ `git config --global --add #{token_name} #{token}`
end
end
- Gitlab.endpoint = endpoint
Gitlab.private_token = token
end
end
end