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
@@ -0,0 +1,187 @@
|
|
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/ui/command_line/command'
|
25
|
+
require 'ronin/cache/overlay'
|
26
|
+
require 'ronin/version'
|
27
|
+
|
28
|
+
require 'fileutils'
|
29
|
+
require 'rexml/document'
|
30
|
+
|
31
|
+
module Ronin
|
32
|
+
module UI
|
33
|
+
module CommandLine
|
34
|
+
class OverlayCommand < Command
|
35
|
+
|
36
|
+
include REXML
|
37
|
+
|
38
|
+
command :overlay
|
39
|
+
|
40
|
+
def initialize
|
41
|
+
@name = nil
|
42
|
+
@source = nil
|
43
|
+
@source_view = nil
|
44
|
+
@website = nil
|
45
|
+
@license = nil
|
46
|
+
@maintainers = []
|
47
|
+
@description = nil
|
48
|
+
|
49
|
+
super
|
50
|
+
end
|
51
|
+
|
52
|
+
def define_options(opts)
|
53
|
+
opts.usage = '[options] PATH'
|
54
|
+
|
55
|
+
opts.options do
|
56
|
+
opts.on('-n','--name NAME','Name of the Overlay') do |name|
|
57
|
+
@name = name
|
58
|
+
end
|
59
|
+
|
60
|
+
opts.on('-S','--source URL','The URL where the source of the Overlay will be hosted') do |url|
|
61
|
+
@source = url
|
62
|
+
end
|
63
|
+
|
64
|
+
opts.on('-V','--source-view URL','The URL for viewing the contents of the Overlay') do |url|
|
65
|
+
@source_view = url
|
66
|
+
end
|
67
|
+
|
68
|
+
opts.on('-U','--website URL','The URL of the website of the Overlay') do |url|
|
69
|
+
@website = url
|
70
|
+
end
|
71
|
+
|
72
|
+
opts.on('-L','--license LICENSE','The license of the contents of the Overlay') do |license|
|
73
|
+
@license = license
|
74
|
+
end
|
75
|
+
|
76
|
+
opts.on('-m','--maintainer "NAME <EMAIL>"','Name of a maintainer of the Overlay') do |text|
|
77
|
+
name = text.scan(/^[^<]+[^<\s]/).first
|
78
|
+
email = text.scan(/<([^<>]+)>\s*$/).first
|
79
|
+
|
80
|
+
email = email.first if email
|
81
|
+
|
82
|
+
@maintainers << {:name => name, :email => email}
|
83
|
+
end
|
84
|
+
|
85
|
+
opts.on('-D','--description TEXT','The description for the Overlay') do |text|
|
86
|
+
@description = text
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
opts.arguments(
|
91
|
+
'PATH' => 'The PATH of the Overlay to be created'
|
92
|
+
)
|
93
|
+
|
94
|
+
opts.summary('Create an empty Overlay at the specified PATH')
|
95
|
+
end
|
96
|
+
|
97
|
+
def arguments(*args)
|
98
|
+
unless args.length == 1
|
99
|
+
fail('only one Overlay path maybe specified')
|
100
|
+
end
|
101
|
+
|
102
|
+
path = File.expand_path(args.first)
|
103
|
+
|
104
|
+
@name ||= File.basename(path).gsub(/[_\s]+/,' ').capitalize
|
105
|
+
@source_view ||= @source
|
106
|
+
@website ||= @source_view
|
107
|
+
|
108
|
+
FileUtils.mkdir_p(path)
|
109
|
+
FileUtils.mkdir_p(File.join(path,'objects'))
|
110
|
+
|
111
|
+
File.open(File.join(path,Cache::Overlay::METADATA_FILE),'w') do |file|
|
112
|
+
doc = Document.new
|
113
|
+
doc.add(XMLDecl.new)
|
114
|
+
doc.add(Instruction.new('xml-stylesheet','type="text/xsl" href="http://ronin.rubyforge.org/dist/overlay.xsl"'))
|
115
|
+
|
116
|
+
root = Element.new('ronin-overlay')
|
117
|
+
root.attributes['version'] = Ronin::VERSION
|
118
|
+
|
119
|
+
name_tag = Element.new('name')
|
120
|
+
name_tag.text = @name
|
121
|
+
root.add_element(name_tag)
|
122
|
+
|
123
|
+
if @source
|
124
|
+
source_tag = Element.new('source')
|
125
|
+
source_tag.text = @source
|
126
|
+
root.add_element(source_tag)
|
127
|
+
end
|
128
|
+
|
129
|
+
if @source_view
|
130
|
+
source_view_tag = Element.new('source-view')
|
131
|
+
source_view_tag.text = @source_view
|
132
|
+
root.add_element(source_view_tag)
|
133
|
+
end
|
134
|
+
|
135
|
+
if @website
|
136
|
+
url_tag = Element.new('website')
|
137
|
+
url_tag.text = @website
|
138
|
+
root.add_element(url_tag)
|
139
|
+
end
|
140
|
+
|
141
|
+
if @license
|
142
|
+
license_tag = Element.new('license')
|
143
|
+
license_tag.text = @license
|
144
|
+
root.add_element(license_tag)
|
145
|
+
end
|
146
|
+
|
147
|
+
unless @maintainers.empty?
|
148
|
+
maintainers_tag = Element.new('maintainers')
|
149
|
+
|
150
|
+
@maintainers.each do |author|
|
151
|
+
if (author[:name] || author[:email])
|
152
|
+
maintainer_tag = Element.new('maintainer')
|
153
|
+
|
154
|
+
if author[:name]
|
155
|
+
name_tag = Element.new('name')
|
156
|
+
name_tag.text = author[:name]
|
157
|
+
maintainer_tag.add_element(name_tag)
|
158
|
+
end
|
159
|
+
|
160
|
+
if author[:email]
|
161
|
+
email_tag = Element.new('email')
|
162
|
+
email_tag.text = author[:email]
|
163
|
+
maintainer_tag.add_element(email_tag)
|
164
|
+
end
|
165
|
+
|
166
|
+
maintainers_tag.add_element(maintainer_tag)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
root.add_element(maintainers_tag)
|
171
|
+
end
|
172
|
+
|
173
|
+
if @description
|
174
|
+
description_tag = Element.new('description')
|
175
|
+
description_tag.text = @description
|
176
|
+
root.add_element(description_tag)
|
177
|
+
end
|
178
|
+
|
179
|
+
doc.add_element(root)
|
180
|
+
doc.write(file,2)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
@@ -21,35 +21,43 @@
|
|
21
21
|
#++
|
22
22
|
#
|
23
23
|
|
24
|
-
require 'ronin/
|
24
|
+
require 'ronin/ui/command_line/command'
|
25
25
|
require 'ronin/cache/overlay'
|
26
26
|
|
27
27
|
module Ronin
|
28
|
-
module
|
29
|
-
|
28
|
+
module UI
|
29
|
+
module CommandLine
|
30
|
+
class RemoveCommand < Command
|
30
31
|
|
31
|
-
|
32
|
+
command :remove, :rm
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
def define_options(opts)
|
35
|
+
opts.usage = 'NAME [...] [options]'
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
opts.options do
|
38
|
+
opts.on('-v','--verbose','Enable verbose output') do
|
39
|
+
@verbose = true
|
40
|
+
end
|
41
|
+
end
|
39
42
|
|
40
|
-
|
41
|
-
|
43
|
+
opts.arguments(
|
44
|
+
'NAME' => 'The repository to remove'
|
45
|
+
)
|
42
46
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
47
|
+
opts.summary('Remove the specified repositories')
|
48
|
+
end
|
49
|
+
|
50
|
+
def arguments(*args)
|
51
|
+
args.each do |name|
|
52
|
+
Cache::Overlay.save_cache do
|
53
|
+
Cache::Overlay.remove(name) do |repo|
|
54
|
+
puts "Removing #{repo}..."
|
55
|
+
end
|
48
56
|
end
|
49
57
|
end
|
50
58
|
end
|
51
|
-
end
|
52
59
|
|
60
|
+
end
|
53
61
|
end
|
54
62
|
end
|
55
63
|
end
|
@@ -21,33 +21,43 @@
|
|
21
21
|
#++
|
22
22
|
#
|
23
23
|
|
24
|
-
require 'ronin/
|
24
|
+
require 'ronin/ui/command_line/command'
|
25
25
|
require 'ronin/cache/overlay'
|
26
26
|
|
27
27
|
module Ronin
|
28
|
-
module
|
29
|
-
|
28
|
+
module UI
|
29
|
+
module CommandLine
|
30
|
+
class UninstallCommand < Command
|
30
31
|
|
31
|
-
|
32
|
+
command :uninstall
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
def define_options(opts)
|
35
|
+
opts.usage = 'NAME [NAME ...] [options]'
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
opts.options do
|
38
|
+
opts.on('-v','--verbose','Enable verbose output') do
|
39
|
+
@verbose = true
|
40
|
+
end
|
41
|
+
end
|
39
42
|
|
40
|
-
|
41
|
-
|
43
|
+
opts.arguments(
|
44
|
+
'NAME' => 'The repository to uninstall'
|
45
|
+
)
|
42
46
|
|
43
|
-
|
44
|
-
if args.empty?
|
45
|
-
Cache::Overlay.each { |repo| repo.update }
|
46
|
-
else
|
47
|
-
args.each { |name| Cache::Overlay.update(name) }
|
47
|
+
opts.summary('Uninstall the specified repositories')
|
48
48
|
end
|
49
|
-
end
|
50
49
|
|
50
|
+
def arguments(*args)
|
51
|
+
args.each do |name|
|
52
|
+
Cache::Overlay.save_cache do
|
53
|
+
Cache::Overlay.uninstall(name) do |repo|
|
54
|
+
puts "Uninstalling #{repo}..."
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
51
61
|
end
|
52
62
|
end
|
53
63
|
end
|
@@ -21,35 +21,41 @@
|
|
21
21
|
#++
|
22
22
|
#
|
23
23
|
|
24
|
-
require 'ronin/
|
24
|
+
require 'ronin/ui/command_line/command'
|
25
25
|
require 'ronin/cache/overlay'
|
26
26
|
|
27
27
|
module Ronin
|
28
|
-
module
|
29
|
-
|
28
|
+
module UI
|
29
|
+
module CommandLine
|
30
|
+
class UpdateCommand < Command
|
30
31
|
|
31
|
-
|
32
|
+
command :update, :up
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
def define_options(opts)
|
35
|
+
opts.usage = '[NAME ...] [options]'
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
opts.options do
|
38
|
+
opts.on('-v','--verbose','Enable verbose output') do
|
39
|
+
@verbose = true
|
40
|
+
end
|
41
|
+
end
|
39
42
|
|
40
|
-
|
41
|
-
|
43
|
+
opts.arguments(
|
44
|
+
'NAME' => 'The repository to update'
|
45
|
+
)
|
42
46
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
opts.summary('Updates all or the specified repositories')
|
48
|
+
end
|
49
|
+
|
50
|
+
def arguments(*args)
|
51
|
+
if args.empty?
|
52
|
+
Cache::Overlay.each { |repo| repo.update }
|
53
|
+
else
|
54
|
+
args.each { |name| Cache::Overlay.update(name) }
|
49
55
|
end
|
50
56
|
end
|
51
|
-
end
|
52
57
|
|
58
|
+
end
|
53
59
|
end
|
54
60
|
end
|
55
61
|
end
|
@@ -0,0 +1,148 @@
|
|
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 'optparse'
|
25
|
+
|
26
|
+
module Ronin
|
27
|
+
module UI
|
28
|
+
module CommandLine
|
29
|
+
class Options < OptionParser
|
30
|
+
|
31
|
+
#
|
32
|
+
# Creates a new Options object with the specified _program_ name
|
33
|
+
# and the given _banner_. If a _block_ is given, it will be passed
|
34
|
+
# the newly created Options object.
|
35
|
+
#
|
36
|
+
def initialize(program,&block)
|
37
|
+
@program = program
|
38
|
+
|
39
|
+
super(&block)
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# Creates a new Options object for a Command with the specified
|
44
|
+
# _program_ name and the given command _name_. If a _block_ is
|
45
|
+
# given, it will be passed the newly created Options object.
|
46
|
+
#
|
47
|
+
def Options.command(program,name=nil,&block)
|
48
|
+
program = program.to_s
|
49
|
+
program << " #{name}" if name
|
50
|
+
|
51
|
+
return Options.new(program,&block)
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# Sets the example usage for the options to the specified _example_.
|
56
|
+
#
|
57
|
+
def usage=(example)
|
58
|
+
self.banner = "Usage: #{@program} #{example}"
|
59
|
+
self.separator ''
|
60
|
+
end
|
61
|
+
|
62
|
+
#
|
63
|
+
# Adds an options section to the help message. If a _block_ is given
|
64
|
+
# it will be called before any default options are added.
|
65
|
+
#
|
66
|
+
def options(&block)
|
67
|
+
self.separator ' Options:'
|
68
|
+
|
69
|
+
block.call() if block
|
70
|
+
|
71
|
+
self.on('-h','--help','print this message') do
|
72
|
+
help
|
73
|
+
exit
|
74
|
+
end
|
75
|
+
|
76
|
+
self.separator ''
|
77
|
+
|
78
|
+
return self
|
79
|
+
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# Creates an arguments section in the help message using the given
|
83
|
+
# _args_.
|
84
|
+
#
|
85
|
+
def arguments(args={})
|
86
|
+
self.separator ' Arguments:'
|
87
|
+
|
88
|
+
args.each do |name,description|
|
89
|
+
self.separator " #{name}\t#{description}"
|
90
|
+
end
|
91
|
+
|
92
|
+
self.separator ''
|
93
|
+
return self
|
94
|
+
end
|
95
|
+
|
96
|
+
#
|
97
|
+
# Addes a summary section with the specified _text_.
|
98
|
+
#
|
99
|
+
def summary(text)
|
100
|
+
self.separator ' Summary:'
|
101
|
+
|
102
|
+
text.each_line do |line|
|
103
|
+
line = line.strip
|
104
|
+
|
105
|
+
self.separator " #{line}" unless line.empty?
|
106
|
+
end
|
107
|
+
|
108
|
+
self.separator ''
|
109
|
+
return self
|
110
|
+
end
|
111
|
+
|
112
|
+
#
|
113
|
+
# Adds a defaults section with the specified _flags_.
|
114
|
+
#
|
115
|
+
def defaults(*flags)
|
116
|
+
self.separator ' Defaults:'
|
117
|
+
|
118
|
+
flags.each { |flag| self.separator " #{flag}" }
|
119
|
+
|
120
|
+
self.separator ''
|
121
|
+
return self
|
122
|
+
end
|
123
|
+
|
124
|
+
#
|
125
|
+
# Prints the help message and exits successfully. If a _block_ is
|
126
|
+
# given it will be called after the help message has been print
|
127
|
+
# and before the Program has exited.
|
128
|
+
#
|
129
|
+
def help(&block)
|
130
|
+
puts self
|
131
|
+
end
|
132
|
+
|
133
|
+
#
|
134
|
+
# Parses the specified _arguments_ and returns any remaining
|
135
|
+
# arguments. If a _block_ is given, it will be passed any
|
136
|
+
# remaining arguments.
|
137
|
+
#
|
138
|
+
def parse(arguments,&block)
|
139
|
+
args = super(arguments)
|
140
|
+
|
141
|
+
block.call(args) if block
|
142
|
+
return args
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|