class Gl::CLI

Public Class Methods

setup() click to toggle source
# File lib/gl/cli.rb, line 22
def self.setup
  Gitlab.endpoint = "https://#{Gl.remote_base}/api/v4/"
  Gl.validate_endpoint!

  token = `git config --get gl.#{Gl.remote_slug}.token`.chomp
  if token.empty?
    prompt = TTY::Prompt.new
    Gl.open_in_browser('profile/personal_access_tokens')
    token = prompt.mask("Please enter your GitLab token for #{Gl.remote_base}")

    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.private_token = token
end