Class: CC::CLI::Init

Inherits:
Command show all
Includes:
Analyzer
Defined in:
lib/cc/cli/init.rb

Constant Summary collapse

ARGUMENT_LIST =
"[--upgrade]".freeze
SHORT_HELP =
"Generate a configuration based on the contents of your repo.".freeze
HELP =
"#{SHORT_HELP}\n" \
"\n" \
"    --upgrade    Upgrade a Code Climate Classic configuration".freeze

Constants included from Analyzer

Analyzer::UnreadableFileError

Constants inherited from Command

Command::CODECLIMATE_YAML, Command::NAMESPACE

Instance Method Summary collapse

Methods inherited from Command

[], abstract!, abstract?, all, command_name, #execute, help, inherited, #initialize, #require_codeclimate_yml, short_help, synopsis

Methods included from Output

#colorize, #fatal, #rainbow, #say, #success, #terminal, #warn

Constructor Details

This class inherits a constructor from CC::CLI::Command

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cc/cli/init.rb', line 16

def run
  if !upgrade? && filesystem.exist?(CODECLIMATE_YAML)
    warn "Config file .codeclimate.yml already present.\nTry running 'validate-config' to check configuration."
    create_default_engine_configs if engines_enabled?
  elsif upgrade? && engines_enabled?
    warn "Config file .codeclimate.yml already configured for the Platform.\nTry running 'validate-config' to check configuration."
    create_codeclimate_checks
    create_default_engine_configs
  else
    generate_all_config
    create_codeclimate_checks
  end
end