Method: Gitlab::CLI::Helpers.confirm_command

Defined in:
lib/gitlab/cli_helpers.rb

.confirm_command(cmd) ⇒ String

Confirms command with a desctructive action.

Returns:

  • (String)


72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/gitlab/cli_helpers.rb', line 72

def confirm_command(cmd)
  return unless cmd.start_with?('remove_', 'delete_')

  puts 'Are you sure? (y/n)'

  if %w[y yes].include?($stdin.gets.to_s.strip.downcase)
    puts 'Proceeding..'
  else
    puts 'Command aborted.'
    exit(1)
  end
end