Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug-info command line option. #118

Merged
merged 1 commit into from
Sep 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ As such, a _Feature_ would map to either major or minor. A _bug fix_ to a patch.
* Distinguish between an activated metric library and an enabled metric.
* An enabled metric will be run.
* An activated metric has had its library required.
* Add --debug-info command line switch to get debug info for Issues. (calveto)
* Fixes
* Misc
* Moved environmental concerns into an Environment module ( Benjamin Fleischer / Robin Curry #91, #111)
Expand Down
11 changes: 11 additions & 0 deletions lib/metric_fu/cli/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def process!(arguments = ARGV)
p.on_tail("-h", "--help", "Show this message") {puts p ; exit}
short = @used_short.include?("v") ? "-V" : "-v"
p.on_tail(short, "--version", "Print version") {puts @version ; exit} unless @version.nil?
p.on_tail("--debug-info", "Print debug info") { debug_info; exit }
@default_values = @result.clone # save default values to reset @result in subsequent calls
end

Expand All @@ -78,6 +79,16 @@ def process!(arguments = ARGV)
@result
end

def debug_info
puts "Ruby"
puts " Version: #{RUBY_VERSION}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. Some suggestions:

Use only methods on MetricFu::Environment (include Environment)

If the method you need isn't there, add it. e.g. ruby_version ruby_platform ruby_engine. See redcard

RedCard.engine => 'ruby'
RedCard.engine_version => '1.9.3'
RbConfig::CONFIG['host_os'] => ''darwin'
RbConfig::CONFIG['host_cpu'] => 'x86_64'
RedCard::CONFIG['build'] => 'java1.6'
RbConfig::CONFIG['build'] => "x86_64-darwin12.4.0" 
RbConfig::CONFIG['prefix'] => "/Users/bfleischer/.rvm/rubies/jruby-1.7.4"
RbConfig::CONFIG['prefix'] => "/Users/bfleischer/.rvm/rubies/ruby-1.9.3-p448"
$VERBOSE => [false, nil, true]
Gem::VERSION
# to consider
Encoding.default_external.to_s => 'UTF-8'
Encoding.default_internal.to_s => ''
RUBY_DESCRIPTION => '=> "jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on Java HotSpot(TM) 64-Bit Server VM 1.6.0_51-b11-456-11M4508 [darwin-x86_64]"
RUBY_PATCHLEVEL => '392'
RUBY_VERSION => '1.9.3'
$LOADED_FEATURES
$LOAD_PATH

MetricFu version is fine, of course, as is.

I'm curious why you're collecting the immediate dependencies. That's what's effectively specified by the gemspec.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to use all those variables, they're just what I thought of while commenting. I'm interested in what you think would be useful, as well.

puts " Platform: #{RUBY_PLATFORM}"
puts " Engine: #{RUBY_ENGINE}"
puts "\nMetricFu"
puts " Version: #{@version}"
puts "\n Dependencies #{`gem dependency metric_fu`}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can put this in a HERE doc

message = <<-NACHOS
Ruby 
  Engine #{ruby_engine}
  Version #{ruby_version}
NACHOS
STDOUT.puts message

end

# Build a nicely formatted list of built-in
# formatter keys and their descriptions
# @see MetricFu::Formatter::BUILTIN_FORMATS
Expand Down