Class: Nasl::Cli
- Inherits:
-
Object
- Object
- Nasl::Cli
- Defined in:
- lib/nasl/cli.rb
Constant Summary collapse
- @@Iterations =
1000
Class Method Summary collapse
Class Method Details
.run ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/nasl/cli.rb', line 33 def self.run cfg = { :iterations => @@Iterations, :verbose => 0 } Command.initialize! optparse = OptionParser.new do |opts| opts. = "Usage: nasl [options] [command [args]]" opts.on('-i', '--iterations=ITERS', 'Benchmarking iterations') do |iters| cfg[:iterations] = iters.to_i || @@Iterations end opts.on('-v', '--verbose', 'Output more information') do cfg[:verbose] += 1 end end optparse.parse! # Sanity check the command line arguments. if ARGV.empty? puts "No command was specified." puts usage exit 1 end cmd = ARGV.shift cls = Command.find(cmd) if cls.nil? then puts "Command '#{cmd}' not supported." puts usage exit 1 end # Run the command. cls.run(cfg, ARGV) end |
.usage ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/nasl/cli.rb', line 76 def self.usage puts "nasl-parse [flags] [command] [path ...]" puts puts "Flags:" puts " -i iters Benchmark the parser running 'iters' iterations, default #@@Iterations." puts " Only valid with the 'benchmark' command." puts " -v Display more verbose (warning) messages." puts " -vv Display more verbose (informational) messages." puts puts "Commands:" puts " benchmark Benchmarks the parsing of the input path(s)." puts " parse Parses the input path(s)." puts " test Runs the specified unit tests, all are selected by default." puts " tokenize Tokenizes the input path(s)." puts " xml Parses the input path(s) and displays them as XML." end |