Class: SlackMessaging::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/slack_messaging/setup.rb

Class Method Summary collapse

Class Method Details

.executeObject

rubocop:disable Metrics/MethodLength rubocop:disable Style/ConditionalAssignment



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/slack_messaging/setup.rb', line 9

def execute
  if config_file_exists?
    answer = highline.ask_yes_no(
      "It looks like the #{default_config} file already exists. Do you wish to edit it? (y/n)",
      { required: true }
    )
  else
    answer = true
  end

  exit unless answer

  type = highline.ask_multiple_choice(
    'Which type of config do you wish to create/update?',
    %w[Discord Slack],
    required: true
  )[:value]

  case type
  when 'Discord'
    file_contents = generate_discord_config_file(ask_discord_config_questions)
  when 'Slack'
    file_contents = generate_slack_config_file(ask_slack_config_questions)
  end

  create_or_update_config_file(file_contents)
end