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
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/pedant/cli.rb', line 33
def self.run
options = {
input_mode: :filesystem,
output_mode: :terminal,
verbosity: 0
}
Command.initialize!
@@optparse = OptionParser.new do |opts|
opts.banner = "Usage: pedant [global-options] [command [command-options] [args]]"
opts.separator ""
opts.separator "Global settings:"
opts.separator ""
opts.separator "Common operations:"
opts.on('-h', '--help', 'Display this help screen.') do
puts opts
exit 1
end
opts.on('-l', '--list', 'Display the list of available commands.') do
puts Command.list
exit 1
end
opts.on('-v') do
puts "The -v argument now comes after the `check` subcommand. Like so:"
puts " pedant check -v file.nasl"
puts "For the version, do -V or --version."
exit 1
end
opts.on('-V', '--version', 'Display the version of Pedant.') do
puts "#{Pedant::VERSION}"
exit
end
end
@@optparse.order!
usage("No command was specified.") if ARGV.empty?
cmd = ARGV.shift
cls = Command.find(cmd)
usage("Command '#{cmd}' not supported.") if cls.nil?
cls.run(options, ARGV)
end
|