drydock 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +19 -4
- data/README.rdoc +37 -28
- data/bin/example +43 -27
- data/drydock.gemspec +1 -25
- data/lib/drydock.rb +308 -119
- metadata +1 -25
- data/doc/classes/Drydock.html +0 -535
- data/doc/classes/Drydock/Command.html +0 -188
- data/doc/classes/Drydock/InvalidArgument.html +0 -118
- data/doc/classes/Drydock/MissingArgument.html +0 -88
- data/doc/classes/Drydock/NoCommandsDefined.html +0 -88
- data/doc/classes/Drydock/UnknownCommand.html +0 -118
- data/doc/created.rid +0 -1
- data/doc/files/CHANGES_txt.html +0 -123
- data/doc/files/LICENSE_txt.html +0 -87
- data/doc/files/README_rdoc.html +0 -127
- data/doc/files/bin/example.html +0 -90
- data/doc/files/lib/drydock_rb.html +0 -75
- data/doc/fr_class_index.html +0 -19
- data/doc/fr_file_index.html +0 -24
- data/doc/fr_method_index.html +0 -4457
- data/doc/index.html +0 -15
- data/doc/rdoc-style.css +0 -319
- data/test/command_test.rb +0 -40
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drydock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Delano Mandelbaum
|
@@ -31,30 +31,6 @@ files:
|
|
31
31
|
- bin/example
|
32
32
|
- drydock.gemspec
|
33
33
|
- lib/drydock.rb
|
34
|
-
- test/command_test.rb
|
35
|
-
- doc
|
36
|
-
- doc/classes
|
37
|
-
- doc/classes/Drydock
|
38
|
-
- doc/classes/Drydock/Command.html
|
39
|
-
- doc/classes/Drydock/InvalidArgument.html
|
40
|
-
- doc/classes/Drydock/MissingArgument.html
|
41
|
-
- doc/classes/Drydock/NoCommandsDefined.html
|
42
|
-
- doc/classes/Drydock/UnknownCommand.html
|
43
|
-
- doc/classes/Drydock.html
|
44
|
-
- doc/created.rid
|
45
|
-
- doc/files
|
46
|
-
- doc/files/bin
|
47
|
-
- doc/files/bin/example.html
|
48
|
-
- doc/files/CHANGES_txt.html
|
49
|
-
- doc/files/lib
|
50
|
-
- doc/files/lib/drydock_rb.html
|
51
|
-
- doc/files/LICENSE_txt.html
|
52
|
-
- doc/files/README_rdoc.html
|
53
|
-
- doc/fr_class_index.html
|
54
|
-
- doc/fr_file_index.html
|
55
|
-
- doc/fr_method_index.html
|
56
|
-
- doc/index.html
|
57
|
-
- doc/rdoc-style.css
|
58
34
|
has_rdoc: true
|
59
35
|
homepage: http://github.com/delano/drydock
|
60
36
|
post_install_message:
|
data/doc/classes/Drydock.html
DELETED
@@ -1,535 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
-
<html lang='en'>
|
3
|
-
<head>
|
4
|
-
<title>Module: Drydock [A seaworthy DSL for writing command line apps]</title>
|
5
|
-
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
|
6
|
-
<link href='.././rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
|
7
|
-
<script type='text/javascript'>
|
8
|
-
//<![CDATA[
|
9
|
-
function popupCode(url) {
|
10
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
11
|
-
}
|
12
|
-
|
13
|
-
function toggleCode(id) {
|
14
|
-
var code = document.getElementById(id)
|
15
|
-
|
16
|
-
code.style.display = code.style.display != 'block' ? 'block' : 'none'
|
17
|
-
return true
|
18
|
-
}
|
19
|
-
|
20
|
-
// Make codeblocks hidden by default
|
21
|
-
document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
|
22
|
-
//]]>
|
23
|
-
</script>
|
24
|
-
</head>
|
25
|
-
<body class='page'>
|
26
|
-
<div class='class' id='wrapper'>
|
27
|
-
<div class='header'>
|
28
|
-
<h1 class='name'>
|
29
|
-
<span class='type'>Module</span>
|
30
|
-
Drydock
|
31
|
-
</h1>
|
32
|
-
<ol class='paths'>
|
33
|
-
<li>
|
34
|
-
<a href="../files/lib/drydock_rb.html">lib/drydock.rb</a>
|
35
|
-
</li>
|
36
|
-
</ol>
|
37
|
-
</div>
|
38
|
-
<div id='content'>
|
39
|
-
<div id='text'>
|
40
|
-
<div id='description'>
|
41
|
-
<hr size="1"></hr><p>
|
42
|
-
<a href="Drydock.html">Drydock</a> is a DSL for command-line apps. See <a
|
43
|
-
href="../files/bin/example.html">bin/example</a> for usage examples.
|
44
|
-
</p>
|
45
|
-
</div>
|
46
|
-
<div id='method-list'>
|
47
|
-
<h2>Methods</h2>
|
48
|
-
<h3>public instance</h3>
|
49
|
-
<ol>
|
50
|
-
<li><a href="#M000006">after</a></li>
|
51
|
-
<li><a href="#M000014">alias_command</a></li>
|
52
|
-
<li><a href="#M000005">before</a></li>
|
53
|
-
<li><a href="#M000013">command</a></li>
|
54
|
-
<li><a href="#M000015">command_alias</a></li>
|
55
|
-
<li><a href="#M000016">commands</a></li>
|
56
|
-
<li><a href="#M000001">debug</a></li>
|
57
|
-
<li><a href="#M000002">debug?</a></li>
|
58
|
-
<li><a href="#M000003">default</a></li>
|
59
|
-
<li><a href="#M000009">get_current_option_parser</a></li>
|
60
|
-
<li><a href="#M000011">global_option</a></li>
|
61
|
-
<li><a href="#M000007">global_usage</a></li>
|
62
|
-
<li><a href="#M000019">has_run?</a></li>
|
63
|
-
<li><a href="#M000010">ignore</a></li>
|
64
|
-
<li><a href="#M000012">option</a></li>
|
65
|
-
<li><a href="#M000020">run!</a></li>
|
66
|
-
<li><a href="#M000018">run=</a></li>
|
67
|
-
<li><a href="#M000017">run?</a></li>
|
68
|
-
<li><a href="#M000004">stdin</a></li>
|
69
|
-
<li><a href="#M000008">usage</a></li>
|
70
|
-
</ol>
|
71
|
-
</div>
|
72
|
-
<div id='section'>
|
73
|
-
<div id='class-list'>
|
74
|
-
<h2>Classes and Modules</h2>
|
75
|
-
Class <a href="Drydock/Command.html" class="link">Drydock::Command</a><br />
|
76
|
-
Class <a href="Drydock/InvalidArgument.html" class="link">Drydock::InvalidArgument</a><br />
|
77
|
-
Class <a href="Drydock/MissingArgument.html" class="link">Drydock::MissingArgument</a><br />
|
78
|
-
Class <a href="Drydock/NoCommandsDefined.html" class="link">Drydock::NoCommandsDefined</a><br />
|
79
|
-
Class <a href="Drydock/UnknownCommand.html" class="link">Drydock::UnknownCommand</a><br />
|
80
|
-
</div>
|
81
|
-
<div id='constants-list'>
|
82
|
-
<h2>Constants</h2>
|
83
|
-
<div class='name-list'>
|
84
|
-
<table summary='Constants'>
|
85
|
-
<tr class='top-aligned-row context-row'>
|
86
|
-
<td class='context-item-name'>VERSION</td>
|
87
|
-
<td>=</td>
|
88
|
-
<td class='context-item-value'>0.3</td>
|
89
|
-
</tr>
|
90
|
-
</table>
|
91
|
-
</div>
|
92
|
-
</div>
|
93
|
-
<div id='methods'>
|
94
|
-
<h2>Public instance methods</h2>
|
95
|
-
<div class='public-instance method' id='method-M000006'>
|
96
|
-
<a name='M000006'> </a>
|
97
|
-
<div class='synopsis'>
|
98
|
-
<span class='name'>after</span>
|
99
|
-
<span class='arguments'>(&b)</span>
|
100
|
-
</div>
|
101
|
-
<div class='description'>
|
102
|
-
<p>
|
103
|
-
Define a block to be called after the command. This is useful for stopping,
|
104
|
-
closing, etc... the stuff in the before block.
|
105
|
-
</p>
|
106
|
-
</div>
|
107
|
-
<div class='source'>
|
108
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000006-source'); return false">
|
109
|
-
[show source]
|
110
|
-
</a>
|
111
|
-
<pre id='M000006-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 177</span>
177: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">after</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
178: <span class="ruby-ivar">@@after_block</span> = <span class="ruby-identifier">b</span>
179: <span class="ruby-keyword kw">end</span></pre>
|
112
|
-
</div>
|
113
|
-
</div>
|
114
|
-
<div class='public-instance method' id='method-M000014'>
|
115
|
-
<a name='M000014'> </a>
|
116
|
-
<div class='synopsis'>
|
117
|
-
<span class='name'>alias_command</span>
|
118
|
-
<span class='arguments'>(aliaz, cmd)</span>
|
119
|
-
</div>
|
120
|
-
<div class='description'>
|
121
|
-
<p>
|
122
|
-
Used to create an alias to a defined command. Here’s an example:
|
123
|
-
</p>
|
124
|
-
<pre>command :task do; ...; end
alias_command :pointer, :task</pre>
|
125
|
-
<p>
|
126
|
-
Either name can be used on the command-line:
|
127
|
-
</p>
|
128
|
-
<pre>$ script task [options]
$ script pointer [options]</pre>
|
129
|
-
<p>
|
130
|
-
Inside of the command definition, you have access to the command name that
|
131
|
-
was used via obj.alias.
|
132
|
-
</p>
|
133
|
-
</div>
|
134
|
-
<div class='source'>
|
135
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000014-source'); return false">
|
136
|
-
[show source]
|
137
|
-
</a>
|
138
|
-
<pre id='M000014-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 286</span>
286: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">alias_command</span>(<span class="ruby-identifier">aliaz</span>, <span class="ruby-identifier">cmd</span>)
287: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">commands</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-identifier">cmd</span>
288: <span class="ruby-ivar">@@commands</span>[<span class="ruby-identifier">aliaz</span>] = <span class="ruby-identifier">commands</span>[<span class="ruby-identifier">cmd</span>]
289: <span class="ruby-keyword kw">end</span></pre>
|
139
|
-
</div>
|
140
|
-
</div>
|
141
|
-
<div class='public-instance method' id='method-M000005'>
|
142
|
-
<a name='M000005'> </a>
|
143
|
-
<div class='synopsis'>
|
144
|
-
<span class='name'>before</span>
|
145
|
-
<span class='arguments'>(&b)</span>
|
146
|
-
</div>
|
147
|
-
<div class='description'>
|
148
|
-
<p>
|
149
|
-
Define a block to be called before the command. This is useful for opening
|
150
|
-
database connections, etc...
|
151
|
-
</p>
|
152
|
-
</div>
|
153
|
-
<div class='source'>
|
154
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000005-source'); return false">
|
155
|
-
[show source]
|
156
|
-
</a>
|
157
|
-
<pre id='M000005-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 171</span>
171: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">before</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
172: <span class="ruby-ivar">@@before_block</span> = <span class="ruby-identifier">b</span>
173: <span class="ruby-keyword kw">end</span></pre>
|
158
|
-
</div>
|
159
|
-
</div>
|
160
|
-
<div class='public-instance method' id='method-M000013'>
|
161
|
-
<a name='M000013'> </a>
|
162
|
-
<div class='synopsis'>
|
163
|
-
<span class='name'>command</span>
|
164
|
-
<span class='arguments'>(*cmds, &b)</span>
|
165
|
-
</div>
|
166
|
-
<div class='description'>
|
167
|
-
<p>
|
168
|
-
Define a command.
|
169
|
-
</p>
|
170
|
-
<pre>command :task do
 ...
end</pre>
|
171
|
-
<p>
|
172
|
-
A custom command class can be specified using Hash syntax. The class must
|
173
|
-
inherit from <a href="Drydock/Command.html">Drydock::Command</a> (class
|
174
|
-
CustomeClass < <a href="Drydock/Command.html">Drydock::Command</a>)
|
175
|
-
</p>
|
176
|
-
<pre>command :task => CustomCommand do
 ...
end</pre>
|
177
|
-
</div>
|
178
|
-
<div class='source'>
|
179
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000013-source'); return false">
|
180
|
-
[show source]
|
181
|
-
</a>
|
182
|
-
<pre id='M000013-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 256</span>
256: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">command</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">cmds</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
257: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>
258: <span class="ruby-ivar">@@command_opts_parser</span> <span class="ruby-operator">||=</span> []
259: <span class="ruby-ivar">@@command_option_names</span> <span class="ruby-operator">||=</span> []
260: <span class="ruby-identifier">cmds</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cmd</span><span class="ruby-operator">|</span> 
261: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cmd</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>
262: <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cmd</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">cmd</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">first</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
263: <span class="ruby-keyword kw">else</span>
264: <span class="ruby-identifier">c</span> = <span class="ruby-constant">Drydock</span><span class="ruby-operator">::</span><span class="ruby-constant">Command</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
265: <span class="ruby-keyword kw">end</span>
266: <span class="ruby-identifier">commands</span>[<span class="ruby-identifier">c</span>.<span class="ruby-identifier">cmd</span>] = <span class="ruby-identifier">c</span>
267: <span class="ruby-identifier">command_index_map</span>[<span class="ruby-identifier">c</span>.<span class="ruby-identifier">cmd</span>] = <span class="ruby-ivar">@@command_index</span>
268: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
269: <span class="ruby-keyword kw">end</span>
270: 
271: <span class="ruby-keyword kw">end</span></pre>
|
183
|
-
</div>
|
184
|
-
</div>
|
185
|
-
<div class='public-instance method' id='method-M000015'>
|
186
|
-
<a name='M000015'> </a>
|
187
|
-
<div class='synopsis'>
|
188
|
-
<span class='name'>command_alias</span>
|
189
|
-
<span class='arguments'>(aliaz, cmd)</span>
|
190
|
-
</div>
|
191
|
-
<div class='description'>
|
192
|
-
<p>
|
193
|
-
Alias for <a href="Drydock.html#M000014">alias_command</a>
|
194
|
-
</p>
|
195
|
-
</div>
|
196
|
-
</div>
|
197
|
-
<div class='public-instance method' id='method-M000016'>
|
198
|
-
<a name='M000016'> </a>
|
199
|
-
<div class='synopsis'>
|
200
|
-
<span class='name'>commands</span>
|
201
|
-
<span class='arguments'>()</span>
|
202
|
-
</div>
|
203
|
-
<div class='description'>
|
204
|
-
<p>
|
205
|
-
An array of the currently defined <a
|
206
|
-
href="Drydock/Command.html">Drydock::Command</a> objects
|
207
|
-
</p>
|
208
|
-
</div>
|
209
|
-
<div class='source'>
|
210
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000016-source'); return false">
|
211
|
-
[show source]
|
212
|
-
</a>
|
213
|
-
<pre id='M000016-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 293</span>
293: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">commands</span>
294: <span class="ruby-ivar">@@commands</span> <span class="ruby-operator">||=</span> {}
295: <span class="ruby-keyword kw">end</span></pre>
|
214
|
-
</div>
|
215
|
-
</div>
|
216
|
-
<div class='public-instance method' id='method-M000001'>
|
217
|
-
<a name='M000001'> </a>
|
218
|
-
<div class='synopsis'>
|
219
|
-
<span class='name'>debug</span>
|
220
|
-
<span class='arguments'>(toggle=false)</span>
|
221
|
-
</div>
|
222
|
-
<div class='description'>
|
223
|
-
<p>
|
224
|
-
Enable or disable debug output.
|
225
|
-
</p>
|
226
|
-
<pre>debug :on
debug :off</pre>
|
227
|
-
<p>
|
228
|
-
Calling without :on or :off will toggle the value.
|
229
|
-
</p>
|
230
|
-
</div>
|
231
|
-
<div class='source'>
|
232
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000001-source'); return false">
|
233
|
-
[show source]
|
234
|
-
</a>
|
235
|
-
<pre id='M000001-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 138</span>
138: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">debug</span>(<span class="ruby-identifier">toggle</span>=<span class="ruby-keyword kw">false</span>)
139: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">toggle</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Symbol</span>
140: <span class="ruby-ivar">@@debug</span> = <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">toggle</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:on</span>
141: <span class="ruby-ivar">@@debug</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">toggle</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:off</span>
142: <span class="ruby-keyword kw">else</span>
143: <span class="ruby-ivar">@@debug</span> = (<span class="ruby-operator">!</span><span class="ruby-ivar">@@debug</span>)
144: <span class="ruby-keyword kw">end</span>
145: <span class="ruby-keyword kw">end</span></pre>
|
236
|
-
</div>
|
237
|
-
</div>
|
238
|
-
<div class='public-instance method' id='method-M000002'>
|
239
|
-
<a name='M000002'> </a>
|
240
|
-
<div class='synopsis'>
|
241
|
-
<span class='name'>debug?</span>
|
242
|
-
<span class='arguments'>()</span>
|
243
|
-
</div>
|
244
|
-
<div class='description'>
|
245
|
-
<p>
|
246
|
-
Returns true if debug output is enabled.
|
247
|
-
</p>
|
248
|
-
</div>
|
249
|
-
<div class='source'>
|
250
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000002-source'); return false">
|
251
|
-
[show source]
|
252
|
-
</a>
|
253
|
-
<pre id='M000002-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 147</span>
147: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">debug?</span>
148: <span class="ruby-ivar">@@debug</span>
149: <span class="ruby-keyword kw">end</span></pre>
|
254
|
-
</div>
|
255
|
-
</div>
|
256
|
-
<div class='public-instance method' id='method-M000003'>
|
257
|
-
<a name='M000003'> </a>
|
258
|
-
<div class='synopsis'>
|
259
|
-
<span class='name'>default</span>
|
260
|
-
<span class='arguments'>(cmd)</span>
|
261
|
-
</div>
|
262
|
-
<div class='description'>
|
263
|
-
<p>
|
264
|
-
Define a default command.
|
265
|
-
</p>
|
266
|
-
<pre>default :task</pre>
|
267
|
-
</div>
|
268
|
-
<div class='source'>
|
269
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000003-source'); return false">
|
270
|
-
[show source]
|
271
|
-
</a>
|
272
|
-
<pre id='M000003-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 155</span>
155: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">default</span>(<span class="ruby-identifier">cmd</span>)
156: <span class="ruby-ivar">@@default_command</span> = <span class="ruby-identifier">canonize</span>(<span class="ruby-identifier">cmd</span>)
157: <span class="ruby-keyword kw">end</span></pre>
|
273
|
-
</div>
|
274
|
-
</div>
|
275
|
-
<div class='public-instance method' id='method-M000009'>
|
276
|
-
<a name='M000009'> </a>
|
277
|
-
<div class='synopsis'>
|
278
|
-
<span class='name'>get_current_option_parser</span>
|
279
|
-
<span class='arguments'>()</span>
|
280
|
-
</div>
|
281
|
-
<div class='description'>
|
282
|
-
<p>
|
283
|
-
Grab the options parser for the current command or create it if it
|
284
|
-
doesn’t exist.
|
285
|
-
</p>
|
286
|
-
</div>
|
287
|
-
<div class='source'>
|
288
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000009-source'); return false">
|
289
|
-
[show source]
|
290
|
-
</a>
|
291
|
-
<pre id='M000009-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 195</span>
195: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_current_option_parser</span>
196: <span class="ruby-ivar">@@command_opts_parser</span> <span class="ruby-operator">||=</span> []
197: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>
198: (<span class="ruby-ivar">@@command_opts_parser</span>[<span class="ruby-ivar">@@command_index</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span>)
199: <span class="ruby-keyword kw">end</span></pre>
|
292
|
-
</div>
|
293
|
-
</div>
|
294
|
-
<div class='public-instance method' id='method-M000011'>
|
295
|
-
<a name='M000011'> </a>
|
296
|
-
<div class='synopsis'>
|
297
|
-
<span class='name'>global_option</span>
|
298
|
-
<span class='arguments'>(*args, &b)</span>
|
299
|
-
</div>
|
300
|
-
<div class='description'>
|
301
|
-
<p>
|
302
|
-
Define a global option. See <tt>option</tt> for more info.
|
303
|
-
</p>
|
304
|
-
</div>
|
305
|
-
<div class='source'>
|
306
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000011-source'); return false">
|
307
|
-
[show source]
|
308
|
-
</a>
|
309
|
-
<pre id='M000011-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 214</span>
214: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">global_option</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
215: <span class="ruby-identifier">args</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">global_opts_parser</span>)
216: <span class="ruby-identifier">global_option_names</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">option_parser</span>(<span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
217: <span class="ruby-keyword kw">end</span></pre>
|
310
|
-
</div>
|
311
|
-
</div>
|
312
|
-
<div class='public-instance method' id='method-M000007'>
|
313
|
-
<a name='M000007'> </a>
|
314
|
-
<div class='synopsis'>
|
315
|
-
<span class='name'>global_usage</span>
|
316
|
-
<span class='arguments'>(msg)</span>
|
317
|
-
</div>
|
318
|
-
<div class='description'>
|
319
|
-
<p>
|
320
|
-
Define the default global usage banner. This is displayed with
|
321
|
-
“script -h”.
|
322
|
-
</p>
|
323
|
-
</div>
|
324
|
-
<div class='source'>
|
325
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000007-source'); return false">
|
326
|
-
[show source]
|
327
|
-
</a>
|
328
|
-
<pre id='M000007-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 183</span>
183: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">global_usage</span>(<span class="ruby-identifier">msg</span>)
184: <span class="ruby-ivar">@@global_options</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">OpenStruct</span>.<span class="ruby-identifier">new</span>
185: <span class="ruby-identifier">global_opts_parser</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">"USAGE: #{msg}"</span>
186: <span class="ruby-keyword kw">end</span></pre>
|
329
|
-
</div>
|
330
|
-
</div>
|
331
|
-
<div class='public-instance method' id='method-M000019'>
|
332
|
-
<a name='M000019'> </a>
|
333
|
-
<div class='synopsis'>
|
334
|
-
<span class='name'>has_run?</span>
|
335
|
-
<span class='arguments'>()</span>
|
336
|
-
</div>
|
337
|
-
<div class='description'>
|
338
|
-
<p>
|
339
|
-
Return true if a command has been executed.
|
340
|
-
</p>
|
341
|
-
</div>
|
342
|
-
<div class='source'>
|
343
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000019-source'); return false">
|
344
|
-
[show source]
|
345
|
-
</a>
|
346
|
-
<pre id='M000019-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 310</span>
310: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_run?</span>
311: <span class="ruby-ivar">@@has_run</span>
312: <span class="ruby-keyword kw">end</span></pre>
|
347
|
-
</div>
|
348
|
-
</div>
|
349
|
-
<div class='public-instance method' id='method-M000010'>
|
350
|
-
<a name='M000010'> </a>
|
351
|
-
<div class='synopsis'>
|
352
|
-
<span class='name'>ignore</span>
|
353
|
-
<span class='arguments'>(what=:nothing)</span>
|
354
|
-
</div>
|
355
|
-
<div class='description'>
|
356
|
-
<p>
|
357
|
-
Tell the <a href="Drydock.html">Drydock</a> parser to ignore something. <a
|
358
|
-
href="Drydock.html">Drydock</a> will currently only listen to you if you
|
359
|
-
tell it to “ignore :options”, otherwise it will ignore you!
|
360
|
-
</p>
|
361
|
-
<p>
|
362
|
-
<tt>what</tt> the thing to ignore. When it equals :options <a
|
363
|
-
href="Drydock.html">Drydock</a> will not parse the command-specific
|
364
|
-
arguments. It will pass the <a href="Drydock/Command.html">Command</a>
|
365
|
-
object the list of arguments. This is useful when you want to parse the
|
366
|
-
arguments in some a way that’s too crazy, dangerous for <a
|
367
|
-
href="Drydock.html">Drydock</a> to handle automatically.
|
368
|
-
</p>
|
369
|
-
</div>
|
370
|
-
<div class='source'>
|
371
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000010-source'); return false">
|
372
|
-
[show source]
|
373
|
-
</a>
|
374
|
-
<pre id='M000010-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 209</span>
209: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ignore</span>(<span class="ruby-identifier">what</span>=<span class="ruby-identifier">:nothing</span>)
210: <span class="ruby-ivar">@@command_opts_parser</span>[<span class="ruby-ivar">@@command_index</span>] = <span class="ruby-identifier">:ignore</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">what</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:options</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">what</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:all</span>
211: <span class="ruby-keyword kw">end</span></pre>
|
375
|
-
</div>
|
376
|
-
</div>
|
377
|
-
<div class='public-instance method' id='method-M000012'>
|
378
|
-
<a name='M000012'> </a>
|
379
|
-
<div class='synopsis'>
|
380
|
-
<span class='name'>option</span>
|
381
|
-
<span class='arguments'>(*args, &b)</span>
|
382
|
-
</div>
|
383
|
-
<div class='description'>
|
384
|
-
<p>
|
385
|
-
Define a command-specific option.
|
386
|
-
</p>
|
387
|
-
<p>
|
388
|
-
<tt>args</tt> is passed directly to OptionParser.on so it can contain
|
389
|
-
anything that’s valid to that method. Some examples: [:h, :help,
|
390
|
-
“Displays this message”] [:m, :max, Integer, “Maximum
|
391
|
-
threshold”] [’-l x,y,z’, ’—lang=x,y,z’,
|
392
|
-
Array, “Requested languages”] If a class is included, it will
|
393
|
-
tell OptionParser to expect a value otherwise it assumes a boolean value.
|
394
|
-
</p>
|
395
|
-
<p>
|
396
|
-
All calls to <tt>option</tt> must come before the command they’re
|
397
|
-
associated to. Example:
|
398
|
-
</p>
|
399
|
-
<pre>option :l, :longname, String, "Description" do; ...; end
command :task do |obj|; ...; end</pre>
|
400
|
-
<p>
|
401
|
-
When calling your script with a specific command-line option, the value is
|
402
|
-
available via obj.longname inside the command block.
|
403
|
-
</p>
|
404
|
-
</div>
|
405
|
-
<div class='source'>
|
406
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000012-source'); return false">
|
407
|
-
[show source]
|
408
|
-
</a>
|
409
|
-
<pre id='M000012-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 238</span>
238: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">option</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
239: <span class="ruby-identifier">args</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">get_current_option_parser</span>)
240: <span class="ruby-identifier">current_command_option_names</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">option_parser</span>(<span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
241: <span class="ruby-keyword kw">end</span></pre>
|
410
|
-
</div>
|
411
|
-
</div>
|
412
|
-
<div class='public-instance method' id='method-M000020'>
|
413
|
-
<a name='M000020'> </a>
|
414
|
-
<div class='synopsis'>
|
415
|
-
<span class='name'>run!</span>
|
416
|
-
<span class='arguments'>(argv=[], stdin=STDIN)</span>
|
417
|
-
</div>
|
418
|
-
<div class='description'>
|
419
|
-
<p>
|
420
|
-
Execute the given command. By default, <a href="Drydock.html">Drydock</a>
|
421
|
-
automatically executes itself and provides handlers for known errors. You
|
422
|
-
can override this functionality by calling <tt><a
|
423
|
-
href="Drydock.html#M000020">Drydock.run!</a></tt> yourself. <a
|
424
|
-
href="Drydock.html">Drydock</a> will only call <tt>run!</tt> once.
|
425
|
-
</p>
|
426
|
-
</div>
|
427
|
-
<div class='source'>
|
428
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000020-source'); return false">
|
429
|
-
[show source]
|
430
|
-
</a>
|
431
|
-
<pre id='M000020-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 318</span>
318: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run!</span>(<span class="ruby-identifier">argv</span>=[], <span class="ruby-identifier">stdin</span>=<span class="ruby-constant">STDIN</span>)
319: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">has_run?</span>
320: <span class="ruby-ivar">@@has_run</span> = <span class="ruby-keyword kw">true</span>
321: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NoCommandsDefined</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">commands</span>.<span class="ruby-identifier">empty?</span>
322: <span class="ruby-ivar">@@global_options</span>, <span class="ruby-identifier">cmd_name</span>, <span class="ruby-ivar">@@command_options</span>, <span class="ruby-identifier">argv</span> = <span class="ruby-identifier">process_arguments</span>(<span class="ruby-identifier">argv</span>)
323: 
324: <span class="ruby-identifier">cmd_name</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">default_command</span>
325: 
326: <span class="ruby-identifier">raise</span> <span class="ruby-constant">UnknownCommand</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">cmd_name</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command?</span>(<span class="ruby-identifier">cmd_name</span>)
327: 
328: <span class="ruby-identifier">stdin</span> = (<span class="ruby-keyword kw">defined?</span> <span class="ruby-ivar">@@stdin_block</span>) <span class="ruby-operator">?</span> <span class="ruby-ivar">@@stdin_block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">stdin</span>, []) <span class="ruby-operator">:</span> <span class="ruby-identifier">stdin</span>
329: <span class="ruby-ivar">@@before_block</span>.<span class="ruby-identifier">call</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">defined?</span> <span class="ruby-ivar">@@before_block</span>
330: 
331: <span class="ruby-identifier">call_command</span>(<span class="ruby-identifier">cmd_name</span>, <span class="ruby-identifier">argv</span>, <span class="ruby-identifier">stdin</span>)
332: 
333: <span class="ruby-ivar">@@after_block</span>.<span class="ruby-identifier">call</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">defined?</span> <span class="ruby-ivar">@@after_block</span>
334: 
335: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidOption</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
336: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Drydock</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidArgument</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ex</span>.<span class="ruby-identifier">args</span>)
337: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">MissingArgument</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
338: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Drydock</span><span class="ruby-operator">::</span><span class="ruby-constant">MissingArgument</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ex</span>.<span class="ruby-identifier">args</span>)
339: <span class="ruby-keyword kw">end</span></pre>
|
432
|
-
</div>
|
433
|
-
</div>
|
434
|
-
<div class='public-instance method' id='method-M000018'>
|
435
|
-
<a name='M000018'> </a>
|
436
|
-
<div class='synopsis'>
|
437
|
-
<span class='name'>run=</span>
|
438
|
-
<span class='arguments'>(v)</span>
|
439
|
-
</div>
|
440
|
-
<div class='description'>
|
441
|
-
<p>
|
442
|
-
Disable automatic execution (enabled by default)
|
443
|
-
</p>
|
444
|
-
<pre>Drydock.run = false</pre>
|
445
|
-
</div>
|
446
|
-
<div class='source'>
|
447
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000018-source'); return false">
|
448
|
-
[show source]
|
449
|
-
</a>
|
450
|
-
<pre id='M000018-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 305</span>
305: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run=</span>(<span class="ruby-identifier">v</span>)
306: <span class="ruby-ivar">@@run</span> = (<span class="ruby-identifier">v</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span> 
307: <span class="ruby-keyword kw">end</span></pre>
|
451
|
-
</div>
|
452
|
-
</div>
|
453
|
-
<div class='public-instance method' id='method-M000017'>
|
454
|
-
<a name='M000017'> </a>
|
455
|
-
<div class='synopsis'>
|
456
|
-
<span class='name'>run?</span>
|
457
|
-
<span class='arguments'>()</span>
|
458
|
-
</div>
|
459
|
-
<div class='description'>
|
460
|
-
<p>
|
461
|
-
Returns true if automatic execution is enabled.
|
462
|
-
</p>
|
463
|
-
</div>
|
464
|
-
<div class='source'>
|
465
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000017-source'); return false">
|
466
|
-
[show source]
|
467
|
-
</a>
|
468
|
-
<pre id='M000017-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 298</span>
298: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run?</span>
299: <span class="ruby-ivar">@@run</span>
300: <span class="ruby-keyword kw">end</span></pre>
|
469
|
-
</div>
|
470
|
-
</div>
|
471
|
-
<div class='public-instance method' id='method-M000004'>
|
472
|
-
<a name='M000004'> </a>
|
473
|
-
<div class='synopsis'>
|
474
|
-
<span class='name'>stdin</span>
|
475
|
-
<span class='arguments'>(&b)</span>
|
476
|
-
</div>
|
477
|
-
<div class='description'>
|
478
|
-
<p>
|
479
|
-
Define a block for processing STDIN before the command is called. The
|
480
|
-
command block receives the return value of this block in a named argument:
|
481
|
-
</p>
|
482
|
-
<pre>command :task do |obj, argv, stdin|; ...; end</pre>
|
483
|
-
<p>
|
484
|
-
If a stdin block isn’t defined, <tt>stdin</tt> above will be the
|
485
|
-
STDIN IO handle.
|
486
|
-
</p>
|
487
|
-
</div>
|
488
|
-
<div class='source'>
|
489
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000004-source'); return false">
|
490
|
-
[show source]
|
491
|
-
</a>
|
492
|
-
<pre id='M000004-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 165</span>
165: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stdin</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
166: <span class="ruby-ivar">@@stdin_block</span> = <span class="ruby-identifier">b</span>
167: <span class="ruby-keyword kw">end</span></pre>
|
493
|
-
</div>
|
494
|
-
</div>
|
495
|
-
<div class='public-instance method' id='method-M000008'>
|
496
|
-
<a name='M000008'> </a>
|
497
|
-
<div class='synopsis'>
|
498
|
-
<span class='name'>usage</span>
|
499
|
-
<span class='arguments'>(msg)</span>
|
500
|
-
</div>
|
501
|
-
<div class='description'>
|
502
|
-
<p>
|
503
|
-
Define a command-specific usage banner. This is displayed with
|
504
|
-
“script command -h“
|
505
|
-
</p>
|
506
|
-
</div>
|
507
|
-
<div class='source'>
|
508
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000008-source'); return false">
|
509
|
-
[show source]
|
510
|
-
</a>
|
511
|
-
<pre id='M000008-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 190</span>
190: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">usage</span>(<span class="ruby-identifier">msg</span>)
191: <span class="ruby-identifier">get_current_option_parser</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">"USAGE: #{msg}"</span>
192: <span class="ruby-keyword kw">end</span></pre>
|
512
|
-
</div>
|
513
|
-
</div>
|
514
|
-
</div>
|
515
|
-
</div>
|
516
|
-
</div>
|
517
|
-
</div>
|
518
|
-
<div id='footer-push'></div>
|
519
|
-
</div>
|
520
|
-
<div id='footer'>
|
521
|
-
<a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
|
522
|
-
<script type='text/javascript'>
|
523
|
-
//<![CDATA[
|
524
|
-
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
525
|
-
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/scr
|
526
|
-
|
527
|
-
try {
|
528
|
-
var pageTracker = _gat._getTracker("UA-4642735-10");
|
529
|
-
pageTracker._trackPageview();
|
530
|
-
} catch(err) {}
|
531
|
-
//]]>
|
532
|
-
</script>
|
533
|
-
</div>
|
534
|
-
</body>
|
535
|
-
</html>
|