Class: PPStats::CommandLine
- Inherits:
-
Object
- Object
- PPStats::CommandLine
- Defined in:
- lib/pp-stats/command-line.rb
Instance Method Summary collapse
-
#initialize(args) ⇒ CommandLine
constructor
A new instance of CommandLine.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ CommandLine
Returns a new instance of CommandLine.
6 7 |
# File 'lib/pp-stats/command-line.rb', line 6 def initialize(args) end |
Instance Method Details
#run ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/pp-stats/command-line.rb', line 9 def run = {} optparse = OptionParser.new do |opts| opts. = "usage: pp-stats [options] modulepath" opts.on('--single-module', 'process a single module') do |flag| [:single_module] = flag end end # Enforce required options and more graceful error handling. begin optparse.parse! # Not using required options anymore but I left it wired up. required = [] missing = required.select { |param| [param].nil? } if not missing.empty? PPStats::Format.errorf("missing options: #{missing.join(', ')}") exit end rescue OptionParser::InvalidOption, OptionParser::MissingArgument PPStats::Format.errorf($!.to_s) # $! is exception object exit end if ARGV.first.nil? [:modulepath] = '.' else [:modulepath] = ARGV.first end if !File.directory? [:modulepath] PPStats::Format.errorf "module folder '#{[:modulepath]}' not found" exit end processor = PPStats::Processor.new() processor.run processor.results end |