Class: Jirify::Subcommands::Setup

Inherits:
Thor
  • Object
show all
Defined in:
lib/jirify/cli/setup.rb

Instance Method Summary collapse

Instance Method Details

#initObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/jirify/cli/setup.rb', line 7

def init
  say 'Welcome! This will guide you through the configuration of the jirify CLI tool.'

  if Config.initialized?
    exit(0) unless yes? 'You seem to have already configured jirify. ' \
      'Do you want to continue and overwrite the current configuration? [Y/n]:'.yellow
  end

  username      = ask 'Enter username:'
  token         = ask 'Enter token (generate from https://id.atlassian.com):'
  site          = ask 'Enter JIRA url:'
  project       = ask 'Enter JIRA Project key:'
  filter_labels = ask 'Enter a comma-separated list of labels to filter by every time (optional):'

  labels = filter_labels.split ', ' if filter_labels

  options = {
    'options' => {
      'username' => username,
      'token'    => token,
      'site'     => site,
      'project'  => project
    }
  }

  options['options']['filter_by_labels'] = labels unless labels.empty?

  Config.write(options)
end

#verboseObject



39
40
41
# File 'lib/jirify/cli/setup.rb', line 39

def verbose
  Config.verbose(options[:enable])
end