lib/slim_lint/cli.rb in slim_lint-0.5.0 vs lib/slim_lint/cli.rb in slim_lint-0.6.0
- old
+ new
@@ -3,11 +3,11 @@
require 'sysexits'
module SlimLint
# Command line application interface.
- class CLI
+ class CLI # rubocop:disable Metrics/ClassLength
# Create a CLI that outputs to the specified logger.
#
# @param logger [SlimLint::Logger]
def initialize(logger)
@log = logger
@@ -36,12 +36,12 @@
log.color_enabled = options.fetch(:color, log.tty?)
if options[:help]
print_help(options)
Sysexits::EX_OK
- elsif options[:version]
- print_version
+ elsif options[:version] || options[:verbose_version]
+ print_version(options)
Sysexits::EX_OK
elsif options[:show_linters]
print_available_linters
Sysexits::EX_OK
elsif options[:show_reporters]
@@ -121,19 +121,34 @@
def print_help(options)
log.log options[:help]
end
# Outputs the application name and version.
- def print_version
+ def print_version(options)
log.log "#{SlimLint::APP_NAME} #{SlimLint::VERSION}"
+
+ if options[:verbose_version]
+ log.log "slim #{Gem.loaded_specs['slim'].version}"
+ log.log "rubocop #{Gem.loaded_specs['rubocop'].version}"
+ log.log RUBY_DESCRIPTION
+ end
end
# Outputs the backtrace of an exception with instructions on how to report
# the issue.
- def print_unexpected_exception(ex)
+ def print_unexpected_exception(ex) # rubocop:disable Metrics/AbcSize
log.bold_error ex.message
log.error ex.backtrace.join("\n")
log.warning 'Report this bug at ', false
log.info SlimLint::BUG_REPORT_URL
+ log.newline
+ log.success 'To help fix this issue, please include:'
+ log.log '- The above stack trace'
+ log.log '- Slim-Lint version: ', false
+ log.info SlimLint::VERSION
+ log.log '- RuboCop version: ', false
+ log.info Gem.loaded_specs['rubocop'].version
+ log.log '- Ruby version: ', false
+ log.info RUBY_VERSION
end
end
end