Sha256: 38250baf7062dd576cc247d6d9f054c7aac953fbd46bc1334ee87d5df0dee49d

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

require 'gl/cli/registry'
require 'gl/cli/merge_requests'
require 'gl/cli/issues'

module Gl
  class CLI < Thor
    desc 'registry', 'handle registry of the project'
    subcommand 'registry', Registry

    desc 'mr', 'handle merge requests of the project'
    subcommand 'mr', MergeRequests

    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

      token = `git config --get gl.#{Gl.remote_slug}.token`.chomp
      if token.empty?
        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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gl-0.2.0 lib/gl/cli.rb