class Nasl::Cli
Public Class Methods
run()
click to toggle source
# File lib/nasl/cli.rb, line 33 def self.run cfg = { :iterations => @@Iterations, :verbose => 0 } Command.initialize! optparse = OptionParser.new do |opts| opts.banner = "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()
click to toggle source
# 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