# frozen_string_literal: true require 'gl/cli/registry' require 'gl/cli/merge_requests' require 'gl/cli/issues' module Gl class CLI < Thor desc 'registry', 'registry' subcommand 'registry', Registry desc 'mr', 'merge requests' subcommand 'mr', MergeRequests desc 'issues', 'issues' subcommand 'issues', Issues def self.setup 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 if token.empty? token = prompt.mask('Please enter your GitLab token') if prompt.yes?('Do you want to persist the tokee as gitlab.token to your git config') `git config --global --add gitlab.token #{token}` end end Gitlab.endpoint = endpoint Gitlab.private_token = token end end end