ronin 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +39 -0
- data/Manifest.txt +46 -34
- data/README.txt +81 -20
- data/Rakefile +6 -4
- data/TODO.txt +1 -5
- data/bin/ronin +2 -2
- data/lib/ronin.rb +3 -3
- data/lib/ronin/arch.rb +5 -3
- data/lib/ronin/author.rb +2 -1
- data/lib/ronin/cache/cache.rb +78 -0
- data/lib/ronin/cache/extension.rb +6 -6
- data/lib/ronin/cache/extension_cache.rb +3 -21
- data/lib/ronin/{parameters/instance_param.rb → cache/maintainer.rb} +22 -17
- data/lib/ronin/cache/overlay.rb +74 -23
- data/lib/ronin/cache/overlay_cache.rb +3 -21
- data/lib/ronin/chars/char_set.rb +114 -31
- data/lib/ronin/chars/chars.rb +20 -10
- data/lib/ronin/{parameters/param.rb → code/emittable.rb} +29 -11
- data/lib/ronin/code/symbol_table.rb +13 -0
- data/lib/ronin/{parameters/class_param.rb → code/token.rb} +37 -10
- data/lib/ronin/config.rb +33 -0
- data/lib/ronin/context.rb +32 -29
- data/lib/ronin/database.rb +1 -2
- data/lib/ronin/extensions.rb +0 -1
- data/lib/ronin/extensions/string.rb +41 -0
- data/lib/ronin/extensions/uri/query_params.rb +8 -0
- data/lib/ronin/formatting/extensions/binary/string.rb +10 -0
- data/lib/ronin/{program.rb → hexdump.rb} +2 -2
- data/lib/ronin/{parameters/exceptions/missing_param.rb → hexdump/extensions.rb} +2 -6
- data/lib/ronin/{extensions/kernel.rb → hexdump/extensions/file.rb} +8 -6
- data/lib/ronin/{persistence.rb → hexdump/extensions/kernel.rb} +7 -6
- data/lib/ronin/hexdump/hexdump.rb +76 -0
- data/lib/ronin/license.rb +5 -3
- data/lib/ronin/model.rb +4 -2
- data/lib/ronin/models.rb +8 -2
- data/lib/ronin/object_context.rb +89 -62
- data/lib/ronin/rpc/console.rb +6 -4
- data/lib/ronin/rpc/shell.rb +4 -4
- data/lib/ronin/sessions/http.rb +144 -0
- data/lib/ronin/sessions/session.rb +2 -1
- data/lib/ronin/sessions/telnet.rb +3 -1
- data/lib/ronin/sessions/udp.rb +1 -1
- data/lib/ronin/sessions/web.rb +7 -2
- data/lib/ronin/translators/translator.rb +75 -0
- data/lib/ronin/ui/command_line.rb +25 -0
- data/lib/ronin/ui/command_line/command.rb +165 -0
- data/lib/ronin/ui/command_line/command_line.rb +117 -0
- data/lib/ronin/{program → ui/command_line}/commands.rb +12 -9
- data/lib/ronin/ui/command_line/commands/add.rb +75 -0
- data/lib/ronin/{program/commands/help.rb → ui/command_line/commands/default.rb} +26 -17
- data/lib/ronin/ui/command_line/commands/extension.rb +85 -0
- data/lib/ronin/ui/command_line/commands/help.rb +70 -0
- data/lib/ronin/{program → ui/command_line}/commands/install.rb +26 -23
- data/lib/ronin/ui/command_line/commands/list.rb +93 -0
- data/lib/ronin/ui/command_line/commands/overlay.rb +187 -0
- data/lib/ronin/{program/commands/uninstall.rb → ui/command_line/commands/remove.rb} +25 -17
- data/lib/ronin/{program/commands/update.rb → ui/command_line/commands/uninstall.rb} +27 -17
- data/lib/ronin/{program/commands/remove.rb → ui/command_line/commands/update.rb} +24 -18
- data/lib/ronin/{program → ui/command_line}/exceptions.rb +1 -1
- data/lib/ronin/{program → ui/command_line}/exceptions/unknown_command.rb +4 -2
- data/lib/ronin/ui/command_line/options.rb +148 -0
- data/lib/ronin/{console.rb → ui/console.rb} +0 -0
- data/lib/ronin/ui/shell.rb +117 -0
- data/lib/ronin/version.rb +1 -1
- data/lib/ronin/web.rb +1 -0
- data/lib/ronin/web/extensions.rb +1 -0
- data/lib/ronin/web/extensions/hpricot.rb +5 -0
- data/lib/ronin/web/extensions/hpricot/comment.rb +19 -0
- data/lib/ronin/web/extensions/hpricot/container.rb +46 -0
- data/lib/ronin/web/extensions/hpricot/doc.rb +21 -0
- data/lib/ronin/web/extensions/hpricot/elem.rb +25 -0
- data/lib/ronin/web/extensions/hpricot/tag.rb +19 -0
- data/lib/ronin/web/extensions/hpricot/text.rb +19 -0
- data/lib/ronin/web/web.rb +70 -4
- data/spec/arch_spec.rb +1 -1
- data/spec/author_spec.rb +1 -1
- data/spec/chars/char_set_spec.rb +177 -0
- data/spec/code/symbol_table_spec.rb +6 -0
- data/spec/extensions/string_spec.rb +12 -0
- data/spec/formatting/binary_spec.rb +9 -0
- data/spec/license_spec.rb +1 -1
- data/spec/object_context/object_context_spec.rb +29 -0
- data/spec/platform_spec.rb +1 -1
- data/spec/product_spec.rb +1 -1
- data/spec/ronin_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -2
- data/spec/target_spec.rb +1 -1
- data/spec/translators/translator_spec.rb +63 -0
- data/spec/web/extensions/hpricot_spec.rb +62 -0
- data/static/extension.rb.erb +16 -0
- data/static/overlay.xsl +103 -0
- data/tasks/spec.rb +2 -0
- metadata +72 -42
- data/FAQ.txt +0 -103
- data/lib/ronin/environment.rb +0 -39
- data/lib/ronin/objects.rb +0 -27
- data/lib/ronin/parameters.rb +0 -27
- data/lib/ronin/parameters/exceptions.rb +0 -25
- data/lib/ronin/parameters/exceptions/param_not_found.rb +0 -29
- data/lib/ronin/parameters/parameters.rb +0 -286
- data/lib/ronin/program/command.rb +0 -203
- data/lib/ronin/program/commands/add.rb +0 -71
- data/lib/ronin/program/commands/list.rb +0 -79
- data/lib/ronin/program/options.rb +0 -201
- data/lib/ronin/program/program.rb +0 -168
- data/lib/ronin/rpc/interactive.rb +0 -55
- data/lib/ronin/rpc/interactive_console.rb +0 -58
- data/lib/ronin/rpc/interactive_shell.rb +0 -59
- data/lib/ronin/shell.rb +0 -81
- data/spec/parameters/parameters_spec.rb +0 -109
@@ -1,203 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#--
|
3
|
-
# Ronin - A Ruby platform designed for information security and data
|
4
|
-
# exploration tasks.
|
5
|
-
#
|
6
|
-
# Copyright (c) 2006-2008 Hal Brodigan (postmodern.mod3 at gmail.com)
|
7
|
-
#
|
8
|
-
# This program is free software; you can redistribute it and/or modify
|
9
|
-
# it under the terms of the GNU General Public License as published by
|
10
|
-
# the Free Software Foundation; either version 2 of the License, or
|
11
|
-
# (at your option) any later version.
|
12
|
-
#
|
13
|
-
# This program is distributed in the hope that it will be useful,
|
14
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
-
# GNU General Public License for more details.
|
17
|
-
#
|
18
|
-
# You should have received a copy of the GNU General Public License
|
19
|
-
# along with this program; if not, write to the Free Software
|
20
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
-
#++
|
22
|
-
#
|
23
|
-
|
24
|
-
require 'ronin/program/options'
|
25
|
-
require 'ronin/program/program'
|
26
|
-
require 'ronin/extensions/meta'
|
27
|
-
|
28
|
-
module Ronin
|
29
|
-
module Program
|
30
|
-
class Command
|
31
|
-
|
32
|
-
#
|
33
|
-
# Creates a new Command object. If a _block_ is given,
|
34
|
-
# it will be passed newly created Command object.
|
35
|
-
#
|
36
|
-
def initialize(&block)
|
37
|
-
@options = nil
|
38
|
-
|
39
|
-
block.call(self) if block
|
40
|
-
end
|
41
|
-
|
42
|
-
#
|
43
|
-
# Returns the name of the command.
|
44
|
-
#
|
45
|
-
def Command.command_name
|
46
|
-
''
|
47
|
-
end
|
48
|
-
|
49
|
-
#
|
50
|
-
# Returns the short names of the command.
|
51
|
-
#
|
52
|
-
def Command.command_short_names
|
53
|
-
[]
|
54
|
-
end
|
55
|
-
|
56
|
-
#
|
57
|
-
# Returns all the names of the command.
|
58
|
-
#
|
59
|
-
def self.command_names
|
60
|
-
[self.command_name] + self.command_short_names
|
61
|
-
end
|
62
|
-
|
63
|
-
#
|
64
|
-
# Creates a new command object and runs it with the
|
65
|
-
# given _args_.
|
66
|
-
#
|
67
|
-
def self.run(*args)
|
68
|
-
self.new.run(*args)
|
69
|
-
end
|
70
|
-
|
71
|
-
#
|
72
|
-
# Prints the help information for the command.
|
73
|
-
#
|
74
|
-
def self.help
|
75
|
-
self.new.help
|
76
|
-
end
|
77
|
-
|
78
|
-
#
|
79
|
-
# Returns the name of the command.
|
80
|
-
#
|
81
|
-
def command_name
|
82
|
-
self.class.command_name
|
83
|
-
end
|
84
|
-
|
85
|
-
#
|
86
|
-
# Returns the short names of the command.
|
87
|
-
#
|
88
|
-
def command_short_names
|
89
|
-
self.class.command_short_names
|
90
|
-
end
|
91
|
-
|
92
|
-
#
|
93
|
-
# Returns all the names of the command.
|
94
|
-
#
|
95
|
-
def command_names
|
96
|
-
self.class.command_names
|
97
|
-
end
|
98
|
-
|
99
|
-
#
|
100
|
-
# Runs the command with the given _args_. If a _block_ is
|
101
|
-
# given, it will be called after the specified _args_ have
|
102
|
-
# been parsed and the command has run.
|
103
|
-
#
|
104
|
-
def run(*args,&block)
|
105
|
-
arguments(*(options.parse(args)))
|
106
|
-
|
107
|
-
@options = nil
|
108
|
-
|
109
|
-
block.call if block
|
110
|
-
return self
|
111
|
-
end
|
112
|
-
|
113
|
-
#
|
114
|
-
# Prints the help information for the command.
|
115
|
-
#
|
116
|
-
def help
|
117
|
-
options.help
|
118
|
-
return self
|
119
|
-
end
|
120
|
-
|
121
|
-
#
|
122
|
-
# Returns the String form of the command.
|
123
|
-
#
|
124
|
-
def to_s
|
125
|
-
names.join(', ')
|
126
|
-
end
|
127
|
-
|
128
|
-
protected
|
129
|
-
|
130
|
-
#
|
131
|
-
# Registers the command with the specified _name_ and the given
|
132
|
-
# _short_names_.
|
133
|
-
#
|
134
|
-
def self.command(name,*short_names)
|
135
|
-
name = name.to_s
|
136
|
-
short_names = short_names.map { |short_name| short_name.to_s }
|
137
|
-
|
138
|
-
meta_def(:command_name) { name }
|
139
|
-
meta_def(:command_short_names) { short_names }
|
140
|
-
|
141
|
-
# register the command
|
142
|
-
Program.commands << self unless Program.commands.include?(self)
|
143
|
-
|
144
|
-
# register the command by name
|
145
|
-
Program.commands_by_name[name] = self
|
146
|
-
|
147
|
-
# register the command by it's short_names
|
148
|
-
short_names.each do |short_name|
|
149
|
-
Program.commands_by_name[short_name] = self
|
150
|
-
end
|
151
|
-
|
152
|
-
return self
|
153
|
-
end
|
154
|
-
|
155
|
-
#
|
156
|
-
# Defines the options of the command with the specified _usage_ and
|
157
|
-
# _block_.
|
158
|
-
#
|
159
|
-
def self.options(usage=nil,&block)
|
160
|
-
class_def(:options) do
|
161
|
-
@options ||= Options.command(:ronin,self.command_name,usage,&block)
|
162
|
-
end
|
163
|
-
|
164
|
-
return self
|
165
|
-
end
|
166
|
-
|
167
|
-
#
|
168
|
-
# Returns the options of the command.
|
169
|
-
#
|
170
|
-
def options
|
171
|
-
@options ||= Options.command(:ronin,command_name)
|
172
|
-
end
|
173
|
-
|
174
|
-
#
|
175
|
-
# See Program.error.
|
176
|
-
#
|
177
|
-
def error(message)
|
178
|
-
Program.error(message)
|
179
|
-
end
|
180
|
-
|
181
|
-
#
|
182
|
-
# See Program.success.
|
183
|
-
#
|
184
|
-
def success(&block)
|
185
|
-
Program.success(&block)
|
186
|
-
end
|
187
|
-
|
188
|
-
#
|
189
|
-
# See Program.fail.
|
190
|
-
#
|
191
|
-
def fail(*messages,&block)
|
192
|
-
Program.fail(*messages,&block)
|
193
|
-
end
|
194
|
-
|
195
|
-
#
|
196
|
-
# Processes the additional arguments specified by _args_.
|
197
|
-
#
|
198
|
-
def arguments(*args)
|
199
|
-
end
|
200
|
-
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#--
|
3
|
-
# Ronin - A Ruby platform designed for information security and data
|
4
|
-
# exploration tasks.
|
5
|
-
#
|
6
|
-
# Copyright (c) 2006-2007 Hal Brodigan (postmodern.mod3 at gmail.com)
|
7
|
-
#
|
8
|
-
# This program is free software; you can redistribute it and/or modify
|
9
|
-
# it under the terms of the GNU General Public License as published by
|
10
|
-
# the Free Software Foundation; either version 2 of the License, or
|
11
|
-
# (at your option) any later version.
|
12
|
-
#
|
13
|
-
# This program is distributed in the hope that it will be useful,
|
14
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
-
# GNU General Public License for more details.
|
17
|
-
#
|
18
|
-
# You should have received a copy of the GNU General Public License
|
19
|
-
# along with this program; if not, write to the Free Software
|
20
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
-
#++
|
22
|
-
#
|
23
|
-
|
24
|
-
require 'ronin/program/command'
|
25
|
-
require 'ronin/cache/overlay'
|
26
|
-
|
27
|
-
module Ronin
|
28
|
-
module Program
|
29
|
-
class AddCommand < Command
|
30
|
-
|
31
|
-
command :add
|
32
|
-
|
33
|
-
options('PATH [options]') do |opts|
|
34
|
-
opts.settings.media = nil
|
35
|
-
opts.settings.uri = nil
|
36
|
-
|
37
|
-
opts.options do
|
38
|
-
opts.on('-m','--media MEDIA','Spedify the media-type of the repository') do |media|
|
39
|
-
opts.settings.media = media
|
40
|
-
end
|
41
|
-
|
42
|
-
opts.on('-U','--uri URI','Specify the source URI of the repository') do |uri|
|
43
|
-
opts.settings.uri = uri
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
opts.arguments do
|
48
|
-
opts.arg('PATH','Add the repository located at the specified PATH')
|
49
|
-
end
|
50
|
-
|
51
|
-
opts.summary('Add a local repository located at the specified PATH to the repository cache')
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
def arguments(*args)
|
56
|
-
unless args.length==1
|
57
|
-
fail('add: only one repository path maybe specified')
|
58
|
-
end
|
59
|
-
|
60
|
-
path = args.first
|
61
|
-
|
62
|
-
Cache::Overlay.save_cache do
|
63
|
-
Cache::Overlay.add(path,options.settings.media,options.settings.uri) do |repo|
|
64
|
-
puts "Overlay #{repo} added."
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#--
|
3
|
-
# Ronin - A Ruby platform designed for information security and data
|
4
|
-
# exploration tasks.
|
5
|
-
#
|
6
|
-
# Copyright (c) 2006-2007 Hal Brodigan (postmodern.mod3 at gmail.com)
|
7
|
-
#
|
8
|
-
# This program is free software; you can redistribute it and/or modify
|
9
|
-
# it under the terms of the GNU General Public License as published by
|
10
|
-
# the Free Software Foundation; either version 2 of the License, or
|
11
|
-
# (at your option) any later version.
|
12
|
-
#
|
13
|
-
# This program is distributed in the hope that it will be useful,
|
14
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
-
# GNU General Public License for more details.
|
17
|
-
#
|
18
|
-
# You should have received a copy of the GNU General Public License
|
19
|
-
# along with this program; if not, write to the Free Software
|
20
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
-
#++
|
22
|
-
#
|
23
|
-
|
24
|
-
require 'ronin/program/command'
|
25
|
-
require 'ronin/cache/overlay'
|
26
|
-
|
27
|
-
module Ronin
|
28
|
-
module Program
|
29
|
-
class ListCommand < Command
|
30
|
-
|
31
|
-
command :list, :ls
|
32
|
-
|
33
|
-
options('[NAME ...] [options]') do |opts|
|
34
|
-
opts.options
|
35
|
-
|
36
|
-
opts.arguments do
|
37
|
-
opts.arg('NAME','Overlay to display')
|
38
|
-
end
|
39
|
-
|
40
|
-
opts.summary('Display all or the specified repositories within the repository cache')
|
41
|
-
end
|
42
|
-
|
43
|
-
def arguments(*args)
|
44
|
-
if args.empty?
|
45
|
-
# list all repositories by name
|
46
|
-
Cache::Overlay.each do |repo|
|
47
|
-
puts " #{repo}"
|
48
|
-
end
|
49
|
-
else
|
50
|
-
# list specified repositories
|
51
|
-
args.each do |name|
|
52
|
-
repo = Cache::Overlay.get(name)
|
53
|
-
|
54
|
-
puts "[ #{repo} ]\n\n"
|
55
|
-
|
56
|
-
puts " path: #{repo.path}" if options.settings.verbose
|
57
|
-
puts " media: #{repo.media}"
|
58
|
-
puts " uri: #{repo.uri}" if repo.uri
|
59
|
-
|
60
|
-
if repo.description
|
61
|
-
puts " description:\n\n #{repo.description}"
|
62
|
-
end
|
63
|
-
|
64
|
-
puts "\n"
|
65
|
-
|
66
|
-
if options.settings.verbose
|
67
|
-
puts " extensions:\n\n"
|
68
|
-
|
69
|
-
repo.each_extension do |ext|
|
70
|
-
puts " #{ext}"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,201 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#--
|
3
|
-
# Ronin - A Ruby platform designed for information security and data
|
4
|
-
# exploration tasks.
|
5
|
-
#
|
6
|
-
# Copyright (c) 2006-2008 Hal Brodigan (postmodern.mod3 at gmail.com)
|
7
|
-
#
|
8
|
-
# This program is free software; you can redistribute it and/or modify
|
9
|
-
# it under the terms of the GNU General Public License as published by
|
10
|
-
# the Free Software Foundation; either version 2 of the License, or
|
11
|
-
# (at your option) any later version.
|
12
|
-
#
|
13
|
-
# This program is distributed in the hope that it will be useful,
|
14
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
-
# GNU General Public License for more details.
|
17
|
-
#
|
18
|
-
# You should have received a copy of the GNU General Public License
|
19
|
-
# along with this program; if not, write to the Free Software
|
20
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
-
#++
|
22
|
-
#
|
23
|
-
|
24
|
-
require 'ronin/program/program'
|
25
|
-
|
26
|
-
require 'optparse'
|
27
|
-
require 'ostruct'
|
28
|
-
|
29
|
-
module Ronin
|
30
|
-
module Program
|
31
|
-
class Options
|
32
|
-
|
33
|
-
# Settings used by the options
|
34
|
-
attr_reader :settings
|
35
|
-
|
36
|
-
#
|
37
|
-
# Creates a new Options object with the specified _program_ name
|
38
|
-
# and the given _banner_. If a _block_ is given, it will be passed
|
39
|
-
# the newly created Options object.
|
40
|
-
#
|
41
|
-
def initialize(program,banner=nil,&block)
|
42
|
-
@settings = OpenStruct.new
|
43
|
-
@settings.verbose = false
|
44
|
-
|
45
|
-
@help_block = proc { help }
|
46
|
-
|
47
|
-
@verbose_block = proc {
|
48
|
-
@settings.verbose = true
|
49
|
-
}
|
50
|
-
|
51
|
-
@parser = OptionParser.new do |opts|
|
52
|
-
if banner
|
53
|
-
opts.banner = "Usage: #{program} #{banner}"
|
54
|
-
opts.separator ''
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
block.call(self) if block
|
59
|
-
end
|
60
|
-
|
61
|
-
#
|
62
|
-
# Creates a new Options object for a Command with the specified
|
63
|
-
# _program_ name, command _name_ and the given _banner_. If a _block_
|
64
|
-
# is given, it will be passed the newly created Options object.
|
65
|
-
#
|
66
|
-
def Options.command(program,name,banner=nil,&block)
|
67
|
-
return Options.new(program,"#{name} #{banner}",&block) if banner
|
68
|
-
return Options.new(program,name,&block)
|
69
|
-
end
|
70
|
-
|
71
|
-
#
|
72
|
-
# Call the specified _block_ when the given option _flags_ are parsed.
|
73
|
-
#
|
74
|
-
def on(*flags,&block)
|
75
|
-
@parser.on(*flags,&block)
|
76
|
-
return self
|
77
|
-
end
|
78
|
-
|
79
|
-
#
|
80
|
-
# Calls the specified _block_ when the verbose option flag is parsed.
|
81
|
-
#
|
82
|
-
def on_verbose(&block)
|
83
|
-
@verbose_block = block
|
84
|
-
return self
|
85
|
-
end
|
86
|
-
|
87
|
-
#
|
88
|
-
# Calls the specified _block_ when the help option-flag is parsed.
|
89
|
-
#
|
90
|
-
def on_help(&block)
|
91
|
-
@help_block = block
|
92
|
-
return self
|
93
|
-
end
|
94
|
-
|
95
|
-
#
|
96
|
-
# Adds a section separator with the specified _text_.
|
97
|
-
#
|
98
|
-
def separator(text)
|
99
|
-
@parser.separator(text)
|
100
|
-
return self
|
101
|
-
end
|
102
|
-
|
103
|
-
#
|
104
|
-
# Adds an options section to the help message. If a _block_ is given
|
105
|
-
# it will be called before any default options are added.
|
106
|
-
#
|
107
|
-
def options(&block)
|
108
|
-
@parser.separator ' Options:'
|
109
|
-
|
110
|
-
block.call(self) if block
|
111
|
-
|
112
|
-
@parser.on('-v','--verbose','produce excess output',&(@verbose_block))
|
113
|
-
@parser.on('-h','--help','print this message',&(@help_block))
|
114
|
-
@parser.separator ''
|
115
|
-
|
116
|
-
return self
|
117
|
-
end
|
118
|
-
|
119
|
-
#
|
120
|
-
# Adds an the argument with the specified _name_ and _description_
|
121
|
-
# to the arguments section of the help message of these options.
|
122
|
-
#
|
123
|
-
def arg(name,description)
|
124
|
-
@parser.separator " #{name}\t#{description}"
|
125
|
-
return self
|
126
|
-
end
|
127
|
-
|
128
|
-
#
|
129
|
-
# Creates an arguments section in the help message and calls the
|
130
|
-
# given _block_.
|
131
|
-
#
|
132
|
-
def arguments(&block)
|
133
|
-
if block
|
134
|
-
@parser.separator ' Arguments:'
|
135
|
-
|
136
|
-
block.call(self)
|
137
|
-
|
138
|
-
@parser.separator ''
|
139
|
-
end
|
140
|
-
|
141
|
-
return self
|
142
|
-
end
|
143
|
-
|
144
|
-
#
|
145
|
-
# Addes a summary section with the specified _lines_.
|
146
|
-
#
|
147
|
-
def summary(*lines)
|
148
|
-
@parser.separator ' Summary:'
|
149
|
-
|
150
|
-
lines.each { |line| @parser.separator " #{line}" }
|
151
|
-
|
152
|
-
@parser.separator ''
|
153
|
-
return self
|
154
|
-
end
|
155
|
-
|
156
|
-
#
|
157
|
-
# Adds a defaults section with the specified _flags_.
|
158
|
-
#
|
159
|
-
def defaults(*flags)
|
160
|
-
@parser.separator ' Defaults:'
|
161
|
-
|
162
|
-
flags.each { |flag| @parser.separator " #{flag}" }
|
163
|
-
|
164
|
-
@parser.separator ''
|
165
|
-
return self
|
166
|
-
end
|
167
|
-
|
168
|
-
#
|
169
|
-
# Prints the help message and exits successfully. If a _block_ is
|
170
|
-
# given it will be called after the help message has been print
|
171
|
-
# and before the Program has exited.
|
172
|
-
#
|
173
|
-
def help(&block)
|
174
|
-
Program.success do
|
175
|
-
puts @parser
|
176
|
-
|
177
|
-
block.call(self) if block
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
#
|
182
|
-
# Parses the specified _argv_ Array. If a _block_ is given it will
|
183
|
-
# be passed the left-over arguments. Returns the left-over arguments.
|
184
|
-
#
|
185
|
-
def parse(argv,&block)
|
186
|
-
args = @parser.parse(argv)
|
187
|
-
|
188
|
-
block.call(self,args) if block
|
189
|
-
return args
|
190
|
-
end
|
191
|
-
|
192
|
-
#
|
193
|
-
# Returns a String representation of the OptParse parser.
|
194
|
-
#
|
195
|
-
def to_s
|
196
|
-
@parser.to_s
|
197
|
-
end
|
198
|
-
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|