Class: Dri::Commands::Init
- Inherits:
-
Dri::Command
- Object
- Dri::Command
- Dri::Commands::Init
- Defined in:
- lib/dri/commands/init.rb
Instance Method Summary collapse
-
#execute(_input: $stdin, output: $stdout) ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#initialize(options) ⇒ Init
constructor
A new instance of Init.
Methods inherited from Dri::Command
#add_color, #api_client, #bold, #command, #config, #cursor, #editor, #emoji, #handover_report_path, #logger, #ops_token, #pastel, #profile, #prompt, #spinner, #timezone, #token, #username, #verify_config_exists
Constructor Details
#initialize(options) ⇒ Init
Returns a new instance of Init.
10 11 12 13 14 15 |
# File 'lib/dri/commands/init.rb', line 10 def initialize() @options = font = TTY::Font.new(:doom) puts pastel.yellow(font.write("DRI")) end |
Instance Method Details
#execute(_input: $stdin, output: $stdout) ⇒ Object
rubocop:disable Metrics/AbcSize
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 53 54 |
# File 'lib/dri/commands/init.rb', line 17 def execute(_input: $stdin, output: $stdout) # rubocop:disable Metrics/AbcSize output.puts "🤖 Welcome to DRI 🤖\n" logger.info "🔎 Scanning for existing configurations...\n" if config.exist? overwrite = prompt.yes?("There is already a configuration initialized. Would you like to overwrite it?") unless overwrite output.puts( "Using existing configuration. To view configuration in use try #{add_color('dri profile', :yellow)}." ) exit 0 end end @username = prompt.ask("What is your GitLab username?") @token = prompt.mask("Please provide your GitLab personal access token:") @ops_token = prompt.mask("Please provide your ops.gitlab.net personal access token:") @timezone = prompt.select("Choose your current timezone?", %w[EMEA AMER APAC]) @emoji = prompt.ask("Have a triage emoji?") @handover_report_path = prompt.ask("Please provide a path for handover report", default: "#{Dir.pwd}/handover_reports") if (@emoji || @token || @username || @ops_token).nil? logger.error "Please provide a username, gitlab token, ops token, timezone and emoji used for triage." exit 1 end config.set(:settings, :user, value: @username) config.set(:settings, :token, value: @token) config.set(:settings, :ops_token, value: @ops_token) config.set(:settings, :timezone, value: @timezone) config.set(:settings, :emoji, value: @emoji) config.set(:settings, :handover_report_path, value: @handover_report_path) config.write(force: true) logger.success "✅ We're ready to go 🚀" end |