Class: CC::CLI::Command
- Inherits:
-
Object
show all
- Defined in:
- lib/cc/cli/command.rb
Constant Summary
collapse
- CODECLIMATE_YAML =
".codeclimate.yml".freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(args = []) ⇒ Command
Returns a new instance of Command.
11
12
13
|
# File 'lib/cc/cli/command.rb', line 11
def initialize(args = [])
@args = args
end
|
Class Method Details
.command_name ⇒ Object
19
20
21
|
# File 'lib/cc/cli/command.rb', line 19
def self.command_name
name[/[^:]*$/].split(/(?=[A-Z])/).map(&:downcase).join('-')
end
|
Instance Method Details
#execute ⇒ Object
23
24
25
|
# File 'lib/cc/cli/command.rb', line 23
def execute
run
end
|
#fatal(message) ⇒ Object
35
36
37
38
|
# File 'lib/cc/cli/command.rb', line 35
def fatal(message)
$stderr.puts colorize(message, :red)
exit 1
end
|
#require_codeclimate_yml ⇒ Object
40
41
42
43
44
|
# File 'lib/cc/cli/command.rb', line 40
def require_codeclimate_yml
if !filesystem.exist?(CODECLIMATE_YAML)
fatal("No '.codeclimate.yml' file found. Run 'codeclimate init' to generate a config file.")
end
end
|
#run ⇒ Object
15
16
17
|
# File 'lib/cc/cli/command.rb', line 15
def run
$stderr.puts "unknown command #{self.class.name.split('::').last.underscore}"
end
|
#say(message) ⇒ Object
27
28
29
|
# File 'lib/cc/cli/command.rb', line 27
def say(message)
terminal.say message
end
|
#warn(message) ⇒ Object
31
32
33
|
# File 'lib/cc/cli/command.rb', line 31
def warn(message)
terminal.say(colorize("WARNING: #{message}", :yellow))
end
|