Class: Gitrob::CLI
- Inherits:
-
Thor
show all
- Defined in:
- lib/gitrob/cli.rb,
lib/gitrob/cli/command.rb,
lib/gitrob/cli/progress_bar.rb,
lib/gitrob/cli/commands/banner.rb,
lib/gitrob/cli/commands/server.rb,
lib/gitrob/cli/commands/analyze.rb,
lib/gitrob/cli/commands/configure.rb,
lib/gitrob/cli/commands/analyze/analysis.rb,
lib/gitrob/cli/commands/analyze/gathering.rb,
lib/gitrob/cli/commands/accept_terms_of_use.rb
Defined Under Namespace
Modules: Commands
Classes: Command, ProgressBar
Constant Summary
collapse
- HELP_COMMANDS =
%w(help h --help -h)
- DB_MIGRATIONS_PATH =
File.expand_path(
"../../../db/migrations", __FILE__
)
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(*args) ⇒ CLI
Returns a new instance of CLI.
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/gitrob/cli.rb', line 45
def initialize(*args)
super
self.class.enable_debugging if options[:debug]
String.disable_colorization(!options[:color])
return if help_command?
banner
configure unless configured?
load_configuration
prepare_database
end
|
Instance Attribute Details
#configuration ⇒ Object
Returns the value of attribute configuration.
12
13
14
|
# File 'lib/gitrob/cli.rb', line 12
def configuration
@configuration
end
|
Class Method Details
.configuration ⇒ Object
209
210
211
|
# File 'lib/gitrob/cli.rb', line 209
def self.configuration
@config
end
|
.configuration=(config) ⇒ Object
205
206
207
|
# File 'lib/gitrob/cli.rb', line 205
def self.configuration=(config)
@config = config
end
|
.debug(message) ⇒ Object
185
186
187
|
# File 'lib/gitrob/cli.rb', line 185
def self.debug(message)
output "[#]".light_cyan + " #{message}\n" if debugging_enabled?
end
|
.debugging_enabled? ⇒ Boolean
rubocop:disable Style/TrivialAccessors
201
202
203
|
# File 'lib/gitrob/cli.rb', line 201
def self.debugging_enabled? @debugging_enabled
end
|
.disable_debugging ⇒ Object
197
198
199
|
# File 'lib/gitrob/cli.rb', line 197
def self.disable_debugging
@debugging_enabled = false
end
|
.enable_debugging ⇒ Object
193
194
195
|
# File 'lib/gitrob/cli.rb', line 193
def self.enable_debugging
@debugging_enabled = true
end
|
.error(message) ⇒ Object
176
177
178
|
# File 'lib/gitrob/cli.rb', line 176
def self.error(message)
output "[!]".light_red + " #{message}\n"
end
|
.fatal(message) ⇒ Object
180
181
182
183
|
# File 'lib/gitrob/cli.rb', line 180
def self.fatal(message)
output "[!]".light_white.on_red + " #{message}\n"
exit(1)
end
|
.info(message) ⇒ Object
149
150
151
|
# File 'lib/gitrob/cli.rb', line 149
def self.info(message)
output "[*]".light_blue + " #{message}\n"
end
|
.output(string) ⇒ Object
189
190
191
|
# File 'lib/gitrob/cli.rb', line 189
def self.output(string)
print string
end
|
.output_failed_task(exception, fatal_error) ⇒ Object
162
163
164
165
166
167
168
169
170
|
# File 'lib/gitrob/cli.rb', line 162
def self.output_failed_task(exception, fatal_error)
message = "#{exception.class}: #{exception.message}"
debug exception.backtrace.join("\n")
if fatal_error
fatal message
else
error message
end
end
|
.task(message, fatal_error = false, &block) ⇒ Object
153
154
155
156
157
158
159
160
|
# File 'lib/gitrob/cli.rb', line 153
def self.task(message, fatal_error=false, &block)
output "[*]".light_blue + " #{message}"
yield block
output " done\n".light_green
rescue => e
output " failed\n".light_red
output_failed_task(e, fatal_error)
end
|
.warn(message) ⇒ Object
172
173
174
|
# File 'lib/gitrob/cli.rb', line 172
def self.warn(message)
output "[!]".light_yellow + " #{message}\n"
end
|
Instance Method Details
#analyze(targets) ⇒ Object