mamertes 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.DS_Store +0 -0
- data/.gitignore +6 -0
- data/.travis-gemfile +15 -0
- data/.travis.yml +10 -0
- data/.yardopts +1 -0
- data/Gemfile +21 -0
- data/README.md +126 -0
- data/Rakefile +29 -0
- data/doc/Mamertes.html +155 -0
- data/doc/Mamertes/Application.html +3057 -0
- data/doc/Mamertes/Command.html +7031 -0
- data/doc/Mamertes/CommandMethods.html +125 -0
- data/doc/Mamertes/CommandMethods/Children.html +1286 -0
- data/doc/Mamertes/CommandMethods/Help.html +209 -0
- data/doc/Mamertes/Error.html +631 -0
- data/doc/Mamertes/Localizer.html +376 -0
- data/doc/Mamertes/Option.html +6671 -0
- data/doc/Mamertes/Parser.html +276 -0
- data/doc/Mamertes/ParserMethods.html +125 -0
- data/doc/Mamertes/ParserMethods/General.html +134 -0
- data/doc/Mamertes/ParserMethods/General/ClassMethods.html +574 -0
- data/doc/Mamertes/Version.html +189 -0
- data/doc/_index.html +276 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +338 -0
- data/doc/file.README.html +198 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +198 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +178 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +509 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/mamertes.rb +18 -0
- data/lib/mamertes/application.rb +206 -0
- data/lib/mamertes/command.rb +529 -0
- data/lib/mamertes/option.rb +236 -0
- data/lib/mamertes/parser.rb +317 -0
- data/lib/mamertes/version.rb +24 -0
- data/locales/en.yml +40 -0
- data/locales/it.yml +40 -0
- data/mamertes.gemspec +30 -0
- data/spec/coverage_helper.rb +20 -0
- data/spec/mamertes/application_spec.rb +181 -0
- data/spec/mamertes/command_spec.rb +526 -0
- data/spec/mamertes/option_spec.rb +274 -0
- data/spec/mamertes/parser_spec.rb +126 -0
- data/spec/spec_helper.rb +15 -0
- metadata +115 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Module: Mamertes::CommandMethods
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.6.2
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '../';
|
20
|
+
framesUrl = "../frames.html#!" + escape(window.location.href);
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="../_index.html">Index (C)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../Mamertes.html" title="Mamertes (module)">Mamertes</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">CommandMethods</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="../class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="../method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="../file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Module: Mamertes::CommandMethods
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<dt class="r1 last">Defined in:</dt>
|
82
|
+
<dd class="r1 last">lib/mamertes/command.rb</dd>
|
83
|
+
|
84
|
+
</dl>
|
85
|
+
<div class="clear"></div>
|
86
|
+
|
87
|
+
<h2>Overview</h2><div class="docstring">
|
88
|
+
<div class="discussion">
|
89
|
+
<p>Methods for the <span class='object_link'><a href="Command.html" title="Mamertes::Command (class)">Command</a></span> class.</p>
|
90
|
+
|
91
|
+
|
92
|
+
</div>
|
93
|
+
</div>
|
94
|
+
<div class="tags">
|
95
|
+
|
96
|
+
|
97
|
+
</div><h2>Defined Under Namespace</h2>
|
98
|
+
<p class="children">
|
99
|
+
|
100
|
+
|
101
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="CommandMethods/Children.html" title="Mamertes::CommandMethods::Children (module)">Children</a></span>, <span class='object_link'><a href="CommandMethods/Help.html" title="Mamertes::CommandMethods::Help (module)">Help</a></span>
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
</p>
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
</div>
|
117
|
+
|
118
|
+
<div id="footer">
|
119
|
+
Generated on Sat Aug 10 16:23:08 2013 by
|
120
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
121
|
+
0.8.6.2 (ruby-1.9.3).
|
122
|
+
</div>
|
123
|
+
|
124
|
+
</body>
|
125
|
+
</html>
|
@@ -0,0 +1,1286 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Module: Mamertes::CommandMethods::Children
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.6.2
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '../../';
|
20
|
+
framesUrl = "../../frames.html#!" + escape(window.location.href);
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="../../_index.html">Index (C)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../../Mamertes.html" title="Mamertes (module)">Mamertes</a></span></span> » <span class='title'><span class='object_link'><a href="../CommandMethods.html" title="Mamertes::CommandMethods (module)">CommandMethods</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">Children</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="../../class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="../../method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="../../file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Module: Mamertes::CommandMethods::Children
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
<dt class="r1">Included in:</dt>
|
81
|
+
<dd class="r1"><span class='object_link'><a href="../Command.html" title="Mamertes::Command (class)">Mamertes::Command</a></span></dd>
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
<dt class="r2 last">Defined in:</dt>
|
86
|
+
<dd class="r2 last">lib/mamertes/command.rb</dd>
|
87
|
+
|
88
|
+
</dl>
|
89
|
+
<div class="clear"></div>
|
90
|
+
|
91
|
+
<h2>Overview</h2><div class="docstring">
|
92
|
+
<div class="discussion">
|
93
|
+
<p>Methods to manage options and subcommands.</p>
|
94
|
+
|
95
|
+
|
96
|
+
</div>
|
97
|
+
</div>
|
98
|
+
<div class="tags">
|
99
|
+
|
100
|
+
|
101
|
+
</div>
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
<h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
|
106
|
+
<ul class="summary">
|
107
|
+
|
108
|
+
<li class="public ">
|
109
|
+
<span class="summary_signature">
|
110
|
+
|
111
|
+
<a href="#commands-instance_method" title="#commands (instance method)">- (HashWithIndifferentAccess) <strong>commands</strong> </a>
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
</span>
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
<span class="note title readonly">readonly</span>
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
<span class="summary_desc"><div class='inline'><p>Returns the list of subcommands of this command.</p>
|
131
|
+
</div></span>
|
132
|
+
|
133
|
+
</li>
|
134
|
+
|
135
|
+
|
136
|
+
<li class="public ">
|
137
|
+
<span class="summary_signature">
|
138
|
+
|
139
|
+
<a href="#options-instance_method" title="#options (instance method)">- (HashWithIndifferentAccess) <strong>options</strong> </a>
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
</span>
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
<span class="note title readonly">readonly</span>
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
<span class="summary_desc"><div class='inline'><p>Returns the list of options of this command.</p>
|
159
|
+
</div></span>
|
160
|
+
|
161
|
+
</li>
|
162
|
+
|
163
|
+
|
164
|
+
</ul>
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
<h2>
|
171
|
+
Instance Method Summary
|
172
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
173
|
+
</h2>
|
174
|
+
|
175
|
+
<ul class="summary">
|
176
|
+
|
177
|
+
<li class="public ">
|
178
|
+
<span class="summary_signature">
|
179
|
+
|
180
|
+
<a href="#argument-instance_method" title="#argument (instance method)">- (Object) <strong>argument</strong>(value) </a>
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
</span>
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
<span class="summary_desc"><div class='inline'><p>Adds a new argument to this command.</p>
|
195
|
+
</div></span>
|
196
|
+
|
197
|
+
</li>
|
198
|
+
|
199
|
+
|
200
|
+
<li class="public ">
|
201
|
+
<span class="summary_signature">
|
202
|
+
|
203
|
+
<a href="#arguments-instance_method" title="#arguments (instance method)">- (Array) <strong>arguments</strong> </a>
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
</span>
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
<span class="summary_desc"><div class='inline'><p>Returns the list of arguments of this command.</p>
|
218
|
+
</div></span>
|
219
|
+
|
220
|
+
</li>
|
221
|
+
|
222
|
+
|
223
|
+
<li class="public ">
|
224
|
+
<span class="summary_signature">
|
225
|
+
|
226
|
+
<a href="#clear_commands-instance_method" title="#clear_commands (instance method)">- (Hash) <strong>clear_commands</strong> </a>
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
</span>
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
<span class="summary_desc"><div class='inline'><p>Clear all subcommands of this commands.</p>
|
241
|
+
</div></span>
|
242
|
+
|
243
|
+
</li>
|
244
|
+
|
245
|
+
|
246
|
+
<li class="public ">
|
247
|
+
<span class="summary_signature">
|
248
|
+
|
249
|
+
<a href="#clear_options-instance_method" title="#clear_options (instance method)">- (Hash) <strong>clear_options</strong> </a>
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
</span>
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
<span class="summary_desc"><div class='inline'><p>Clear all the options of this commands.</p>
|
264
|
+
</div></span>
|
265
|
+
|
266
|
+
</li>
|
267
|
+
|
268
|
+
|
269
|
+
<li class="public ">
|
270
|
+
<span class="summary_signature">
|
271
|
+
|
272
|
+
<a href="#command-instance_method" title="#command (instance method)">- (Command) <strong>command</strong>(name, options = {}, &block) </a>
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
</span>
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
<span class="summary_desc"><div class='inline'><p>Adds a new subcommand to this command.</p>
|
287
|
+
</div></span>
|
288
|
+
|
289
|
+
</li>
|
290
|
+
|
291
|
+
|
292
|
+
<li class="public ">
|
293
|
+
<span class="summary_signature">
|
294
|
+
|
295
|
+
<a href="#get_options-instance_method" title="#get_options (instance method)">- (HashWithIndifferentAccess) <strong>get_options</strong>(unprovided = false, application = "application_", prefix = "", *whitelist) </a>
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
</span>
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
<span class="summary_desc"><div class='inline'><p>Get the list of the options of this command as an hash, where the keys are the options and the values are either
|
310
|
+
the user inputs or the defaults values.</p>
|
311
|
+
</div></span>
|
312
|
+
|
313
|
+
</li>
|
314
|
+
|
315
|
+
|
316
|
+
<li class="public ">
|
317
|
+
<span class="summary_signature">
|
318
|
+
|
319
|
+
<a href="#has_commands%3F-instance_method" title="#has_commands? (instance method)">- (Boolean) <strong>has_commands?</strong> </a>
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
</span>
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
<span class="summary_desc"><div class='inline'><p>Check if this command has subcommands.</p>
|
334
|
+
</div></span>
|
335
|
+
|
336
|
+
</li>
|
337
|
+
|
338
|
+
|
339
|
+
<li class="public ">
|
340
|
+
<span class="summary_signature">
|
341
|
+
|
342
|
+
<a href="#has_options%3F-instance_method" title="#has_options? (instance method)">- (Boolean) <strong>has_options?</strong> </a>
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
</span>
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
<span class="summary_desc"><div class='inline'><p>Check if this command has options.</p>
|
357
|
+
</div></span>
|
358
|
+
|
359
|
+
</li>
|
360
|
+
|
361
|
+
|
362
|
+
<li class="public ">
|
363
|
+
<span class="summary_signature">
|
364
|
+
|
365
|
+
<a href="#option-instance_method" title="#option (instance method)">- (Option) <strong>option</strong>(name, forms = [], options = {}, &action) </a>
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
</span>
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
<span class="summary_desc"><div class='inline'><p>Adds a new option to this command.</p>
|
380
|
+
</div></span>
|
381
|
+
|
382
|
+
</li>
|
383
|
+
|
384
|
+
|
385
|
+
</ul>
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
<div id="instance_attr_details" class="attr_details">
|
390
|
+
<h2>Instance Attribute Details</h2>
|
391
|
+
|
392
|
+
|
393
|
+
<span id=""></span>
|
394
|
+
<div class="method_details first">
|
395
|
+
<h3 class="signature first" id="commands-instance_method">
|
396
|
+
|
397
|
+
- (<tt>HashWithIndifferentAccess</tt>) <strong>commands</strong> <span class="extras">(readonly)</span>
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
</h3><div class="docstring">
|
404
|
+
<div class="discussion">
|
405
|
+
<p>Returns the list of subcommands of this command.</p>
|
406
|
+
|
407
|
+
|
408
|
+
</div>
|
409
|
+
</div>
|
410
|
+
<div class="tags">
|
411
|
+
|
412
|
+
<p class="tag_title">Returns:</p>
|
413
|
+
<ul class="return">
|
414
|
+
|
415
|
+
<li>
|
416
|
+
|
417
|
+
|
418
|
+
<span class='type'>(<tt>HashWithIndifferentAccess</tt>)</span>
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
—
|
423
|
+
<div class='inline'><p>The list of subcommands of this command.</p>
|
424
|
+
</div>
|
425
|
+
|
426
|
+
</li>
|
427
|
+
|
428
|
+
</ul>
|
429
|
+
|
430
|
+
</div><table class="source_code">
|
431
|
+
<tr>
|
432
|
+
<td>
|
433
|
+
<pre class="lines">
|
434
|
+
|
435
|
+
|
436
|
+
181
|
437
|
+
182
|
438
|
+
183</pre>
|
439
|
+
</td>
|
440
|
+
<td>
|
441
|
+
<pre class="code"><span class="info file"># File 'lib/mamertes/command.rb', line 181</span>
|
442
|
+
|
443
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_commands'>commands</span>
|
444
|
+
<span class='ivar'>@commands</span>
|
445
|
+
<span class='kw'>end</span></pre>
|
446
|
+
</td>
|
447
|
+
</tr>
|
448
|
+
</table>
|
449
|
+
</div>
|
450
|
+
|
451
|
+
|
452
|
+
<span id=""></span>
|
453
|
+
<div class="method_details ">
|
454
|
+
<h3 class="signature " id="options-instance_method">
|
455
|
+
|
456
|
+
- (<tt>HashWithIndifferentAccess</tt>) <strong>options</strong> <span class="extras">(readonly)</span>
|
457
|
+
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
|
462
|
+
</h3><div class="docstring">
|
463
|
+
<div class="discussion">
|
464
|
+
<p>Returns the list of options of this command.</p>
|
465
|
+
|
466
|
+
|
467
|
+
</div>
|
468
|
+
</div>
|
469
|
+
<div class="tags">
|
470
|
+
|
471
|
+
<p class="tag_title">Returns:</p>
|
472
|
+
<ul class="return">
|
473
|
+
|
474
|
+
<li>
|
475
|
+
|
476
|
+
|
477
|
+
<span class='type'>(<tt>HashWithIndifferentAccess</tt>)</span>
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
—
|
482
|
+
<div class='inline'><p>The list of options of this command.</p>
|
483
|
+
</div>
|
484
|
+
|
485
|
+
</li>
|
486
|
+
|
487
|
+
</ul>
|
488
|
+
|
489
|
+
</div><table class="source_code">
|
490
|
+
<tr>
|
491
|
+
<td>
|
492
|
+
<pre class="lines">
|
493
|
+
|
494
|
+
|
495
|
+
202
|
496
|
+
203
|
497
|
+
204</pre>
|
498
|
+
</td>
|
499
|
+
<td>
|
500
|
+
<pre class="code"><span class="info file"># File 'lib/mamertes/command.rb', line 202</span>
|
501
|
+
|
502
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_options'>options</span>
|
503
|
+
<span class='ivar'>@options</span>
|
504
|
+
<span class='kw'>end</span></pre>
|
505
|
+
</td>
|
506
|
+
</tr>
|
507
|
+
</table>
|
508
|
+
</div>
|
509
|
+
|
510
|
+
</div>
|
511
|
+
|
512
|
+
|
513
|
+
<div id="instance_method_details" class="method_details_list">
|
514
|
+
<h2>Instance Method Details</h2>
|
515
|
+
|
516
|
+
|
517
|
+
<div class="method_details first">
|
518
|
+
<h3 class="signature first" id="argument-instance_method">
|
519
|
+
|
520
|
+
- (<tt>Object</tt>) <strong>argument</strong>(value)
|
521
|
+
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
|
526
|
+
</h3><div class="docstring">
|
527
|
+
<div class="discussion">
|
528
|
+
<p>Adds a new argument to this command.</p>
|
529
|
+
|
530
|
+
|
531
|
+
</div>
|
532
|
+
</div>
|
533
|
+
<div class="tags">
|
534
|
+
<p class="tag_title">Parameters:</p>
|
535
|
+
<ul class="param">
|
536
|
+
|
537
|
+
<li>
|
538
|
+
|
539
|
+
<span class='name'>value</span>
|
540
|
+
|
541
|
+
|
542
|
+
<span class='type'>(<tt>String</tt>)</span>
|
543
|
+
|
544
|
+
|
545
|
+
|
546
|
+
—
|
547
|
+
<div class='inline'><p>The argument to add.</p>
|
548
|
+
</div>
|
549
|
+
|
550
|
+
</li>
|
551
|
+
|
552
|
+
</ul>
|
553
|
+
|
554
|
+
|
555
|
+
</div><table class="source_code">
|
556
|
+
<tr>
|
557
|
+
<td>
|
558
|
+
<pre class="lines">
|
559
|
+
|
560
|
+
|
561
|
+
222
|
562
|
+
223
|
563
|
+
224
|
564
|
+
225</pre>
|
565
|
+
</td>
|
566
|
+
<td>
|
567
|
+
<pre class="code"><span class="info file"># File 'lib/mamertes/command.rb', line 222</span>
|
568
|
+
|
569
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_argument'>argument</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
570
|
+
<span class='ivar'>@args</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
571
|
+
<span class='ivar'>@args</span> <span class='op'><<</span> <span class='id identifier rubyid_value'>value</span>
|
572
|
+
<span class='kw'>end</span></pre>
|
573
|
+
</td>
|
574
|
+
</tr>
|
575
|
+
</table>
|
576
|
+
</div>
|
577
|
+
|
578
|
+
<div class="method_details ">
|
579
|
+
<h3 class="signature " id="arguments-instance_method">
|
580
|
+
|
581
|
+
- (<tt>Array</tt>) <strong>arguments</strong>
|
582
|
+
|
583
|
+
|
584
|
+
|
585
|
+
|
586
|
+
|
587
|
+
</h3><div class="docstring">
|
588
|
+
<div class="discussion">
|
589
|
+
<p>Returns the list of arguments of this command.</p>
|
590
|
+
|
591
|
+
|
592
|
+
</div>
|
593
|
+
</div>
|
594
|
+
<div class="tags">
|
595
|
+
|
596
|
+
<p class="tag_title">Returns:</p>
|
597
|
+
<ul class="return">
|
598
|
+
|
599
|
+
<li>
|
600
|
+
|
601
|
+
|
602
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
603
|
+
|
604
|
+
|
605
|
+
|
606
|
+
—
|
607
|
+
<div class='inline'><p>The list of arguments of this command.</p>
|
608
|
+
</div>
|
609
|
+
|
610
|
+
</li>
|
611
|
+
|
612
|
+
</ul>
|
613
|
+
|
614
|
+
</div><table class="source_code">
|
615
|
+
<tr>
|
616
|
+
<td>
|
617
|
+
<pre class="lines">
|
618
|
+
|
619
|
+
|
620
|
+
230
|
621
|
+
231
|
622
|
+
232</pre>
|
623
|
+
</td>
|
624
|
+
<td>
|
625
|
+
<pre class="code"><span class="info file"># File 'lib/mamertes/command.rb', line 230</span>
|
626
|
+
|
627
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_arguments'>arguments</span>
|
628
|
+
<span class='ivar'>@args</span> <span class='op'>||</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
629
|
+
<span class='kw'>end</span></pre>
|
630
|
+
</td>
|
631
|
+
</tr>
|
632
|
+
</table>
|
633
|
+
</div>
|
634
|
+
|
635
|
+
<div class="method_details ">
|
636
|
+
<h3 class="signature " id="clear_commands-instance_method">
|
637
|
+
|
638
|
+
- (<tt>Hash</tt>) <strong>clear_commands</strong>
|
639
|
+
|
640
|
+
|
641
|
+
|
642
|
+
|
643
|
+
|
644
|
+
</h3><div class="docstring">
|
645
|
+
<div class="discussion">
|
646
|
+
<p>Clear all subcommands of this commands.</p>
|
647
|
+
|
648
|
+
|
649
|
+
</div>
|
650
|
+
</div>
|
651
|
+
<div class="tags">
|
652
|
+
|
653
|
+
<p class="tag_title">Returns:</p>
|
654
|
+
<ul class="return">
|
655
|
+
|
656
|
+
<li>
|
657
|
+
|
658
|
+
|
659
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
660
|
+
|
661
|
+
|
662
|
+
|
663
|
+
—
|
664
|
+
<div class='inline'><p>The new (empty) list of subcommands of this command.</p>
|
665
|
+
</div>
|
666
|
+
|
667
|
+
</li>
|
668
|
+
|
669
|
+
</ul>
|
670
|
+
|
671
|
+
</div><table class="source_code">
|
672
|
+
<tr>
|
673
|
+
<td>
|
674
|
+
<pre class="lines">
|
675
|
+
|
676
|
+
|
677
|
+
188
|
678
|
+
189
|
679
|
+
190</pre>
|
680
|
+
</td>
|
681
|
+
<td>
|
682
|
+
<pre class="code"><span class="info file"># File 'lib/mamertes/command.rb', line 188</span>
|
683
|
+
|
684
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_clear_commands'>clear_commands</span>
|
685
|
+
<span class='ivar'>@commands</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
686
|
+
<span class='kw'>end</span></pre>
|
687
|
+
</td>
|
688
|
+
</tr>
|
689
|
+
</table>
|
690
|
+
</div>
|
691
|
+
|
692
|
+
<div class="method_details ">
|
693
|
+
<h3 class="signature " id="clear_options-instance_method">
|
694
|
+
|
695
|
+
- (<tt>Hash</tt>) <strong>clear_options</strong>
|
696
|
+
|
697
|
+
|
698
|
+
|
699
|
+
|
700
|
+
|
701
|
+
</h3><div class="docstring">
|
702
|
+
<div class="discussion">
|
703
|
+
<p>Clear all the options of this commands.</p>
|
704
|
+
|
705
|
+
|
706
|
+
</div>
|
707
|
+
</div>
|
708
|
+
<div class="tags">
|
709
|
+
|
710
|
+
<p class="tag_title">Returns:</p>
|
711
|
+
<ul class="return">
|
712
|
+
|
713
|
+
<li>
|
714
|
+
|
715
|
+
|
716
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
717
|
+
|
718
|
+
|
719
|
+
|
720
|
+
—
|
721
|
+
<div class='inline'><p>The new (empty) list of the options of this command.</p>
|
722
|
+
</div>
|
723
|
+
|
724
|
+
</li>
|
725
|
+
|
726
|
+
</ul>
|
727
|
+
|
728
|
+
</div><table class="source_code">
|
729
|
+
<tr>
|
730
|
+
<td>
|
731
|
+
<pre class="lines">
|
732
|
+
|
733
|
+
|
734
|
+
208
|
735
|
+
209
|
736
|
+
210</pre>
|
737
|
+
</td>
|
738
|
+
<td>
|
739
|
+
<pre class="code"><span class="info file"># File 'lib/mamertes/command.rb', line 208</span>
|
740
|
+
|
741
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_clear_options'>clear_options</span>
|
742
|
+
<span class='ivar'>@options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
743
|
+
<span class='kw'>end</span></pre>
|
744
|
+
</td>
|
745
|
+
</tr>
|
746
|
+
</table>
|
747
|
+
</div>
|
748
|
+
|
749
|
+
<div class="method_details ">
|
750
|
+
<h3 class="signature " id="command-instance_method">
|
751
|
+
|
752
|
+
- (<tt><span class='object_link'><a href="../Command.html" title="Mamertes::Command (class)">Command</a></span></tt>) <strong>command</strong>(name, options = {}, &block)
|
753
|
+
|
754
|
+
|
755
|
+
|
756
|
+
|
757
|
+
|
758
|
+
</h3><div class="docstring">
|
759
|
+
<div class="discussion">
|
760
|
+
<p>Adds a new subcommand to this command.</p>
|
761
|
+
|
762
|
+
|
763
|
+
</div>
|
764
|
+
</div>
|
765
|
+
<div class="tags">
|
766
|
+
<p class="tag_title">Parameters:</p>
|
767
|
+
<ul class="param">
|
768
|
+
|
769
|
+
<li>
|
770
|
+
|
771
|
+
<span class='name'>name</span>
|
772
|
+
|
773
|
+
|
774
|
+
<span class='type'>(<tt>String</tt>)</span>
|
775
|
+
|
776
|
+
|
777
|
+
|
778
|
+
—
|
779
|
+
<div class='inline'><p>The name of this command. Must be unique.</p>
|
780
|
+
</div>
|
781
|
+
|
782
|
+
</li>
|
783
|
+
|
784
|
+
<li>
|
785
|
+
|
786
|
+
<span class='name'>options</span>
|
787
|
+
|
788
|
+
|
789
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
790
|
+
|
791
|
+
|
792
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
793
|
+
|
794
|
+
|
795
|
+
—
|
796
|
+
<div class='inline'><p>A set of options for this command.</p>
|
797
|
+
</div>
|
798
|
+
|
799
|
+
</li>
|
800
|
+
|
801
|
+
</ul>
|
802
|
+
|
803
|
+
<p class="tag_title">Returns:</p>
|
804
|
+
<ul class="return">
|
805
|
+
|
806
|
+
<li>
|
807
|
+
|
808
|
+
|
809
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Command.html" title="Mamertes::Command (class)">Command</a></span></tt>)</span>
|
810
|
+
|
811
|
+
|
812
|
+
|
813
|
+
—
|
814
|
+
<div class='inline'><p>The newly added command.</p>
|
815
|
+
</div>
|
816
|
+
|
817
|
+
</li>
|
818
|
+
|
819
|
+
</ul>
|
820
|
+
<p class="tag_title">Raises:</p>
|
821
|
+
<ul class="raise">
|
822
|
+
|
823
|
+
<li>
|
824
|
+
|
825
|
+
|
826
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Error.html" title="Mamertes::Error (class)">Mamertes::Error</a></span></tt>)</span>
|
827
|
+
|
828
|
+
|
829
|
+
|
830
|
+
</li>
|
831
|
+
|
832
|
+
</ul>
|
833
|
+
|
834
|
+
</div><table class="source_code">
|
835
|
+
<tr>
|
836
|
+
<td>
|
837
|
+
<pre class="lines">
|
838
|
+
|
839
|
+
|
840
|
+
142
|
841
|
+
143
|
842
|
+
144
|
843
|
+
145
|
844
|
+
146
|
845
|
+
147
|
846
|
+
148
|
847
|
+
149</pre>
|
848
|
+
</td>
|
849
|
+
<td>
|
850
|
+
<pre class="code"><span class="info file"># File 'lib/mamertes/command.rb', line 142</span>
|
851
|
+
|
852
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_command'>command</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
853
|
+
<span class='ivar'>@commands</span> <span class='op'>||=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
854
|
+
|
855
|
+
<span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='label'>name:</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='comma'>,</span> <span class='label'>parent:</span> <span class='kw'>self</span><span class='comma'>,</span> <span class='label'>application:</span> <span class='id identifier rubyid_application'>application</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='rparen'>)</span>
|
856
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Mamertes</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:duplicate_command</span><span class='comma'>,</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_existing_command'>existing_command</span><span class='lparen'>(</span><span class='id identifier rubyid_full_name'>full_name</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='ivar'>@commands</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rbracket'>]</span>
|
857
|
+
|
858
|
+
<span class='id identifier rubyid_create_command'>create_command</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
859
|
+
<span class='kw'>end</span></pre>
|
860
|
+
</td>
|
861
|
+
</tr>
|
862
|
+
</table>
|
863
|
+
</div>
|
864
|
+
|
865
|
+
<div class="method_details ">
|
866
|
+
<h3 class="signature " id="get_options-instance_method">
|
867
|
+
|
868
|
+
- (<tt>HashWithIndifferentAccess</tt>) <strong>get_options</strong>(unprovided = false, application = "application_", prefix = "", *whitelist)
|
869
|
+
|
870
|
+
|
871
|
+
|
872
|
+
|
873
|
+
|
874
|
+
</h3><div class="docstring">
|
875
|
+
<div class="discussion">
|
876
|
+
<p>Get the list of the options of this command as an hash, where the keys are the options and the values are either
|
877
|
+
the user inputs or the defaults values.</p>
|
878
|
+
|
879
|
+
<p>If the two prefixes collides, the command options take precedence over application options.</p>
|
880
|
+
|
881
|
+
|
882
|
+
</div>
|
883
|
+
</div>
|
884
|
+
<div class="tags">
|
885
|
+
<p class="tag_title">Parameters:</p>
|
886
|
+
<ul class="param">
|
887
|
+
|
888
|
+
<li>
|
889
|
+
|
890
|
+
<span class='name'>unprovided</span>
|
891
|
+
|
892
|
+
|
893
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
894
|
+
|
895
|
+
|
896
|
+
<em class="default">(defaults to: <tt>false</tt>)</em>
|
897
|
+
|
898
|
+
|
899
|
+
—
|
900
|
+
<div class='inline'><p>If to include also options that were not provided by the user and that don’t have any default value.</p>
|
901
|
+
</div>
|
902
|
+
|
903
|
+
</li>
|
904
|
+
|
905
|
+
<li>
|
906
|
+
|
907
|
+
<span class='name'>application</span>
|
908
|
+
|
909
|
+
|
910
|
+
<span class='type'>(<tt>String</tt>)</span>
|
911
|
+
|
912
|
+
|
913
|
+
<em class="default">(defaults to: <tt>"application_"</tt>)</em>
|
914
|
+
|
915
|
+
|
916
|
+
—
|
917
|
+
<div class='inline'><p>The prefix to use for including application’s options. If falsy, only current command options will be included.</p>
|
918
|
+
</div>
|
919
|
+
|
920
|
+
</li>
|
921
|
+
|
922
|
+
<li>
|
923
|
+
|
924
|
+
<span class='name'>prefix</span>
|
925
|
+
|
926
|
+
|
927
|
+
<span class='type'>(<tt>String</tt>)</span>
|
928
|
+
|
929
|
+
|
930
|
+
<em class="default">(defaults to: <tt>""</tt>)</em>
|
931
|
+
|
932
|
+
|
933
|
+
—
|
934
|
+
<div class='inline'><p>The prefix to add to the option of this command.</p>
|
935
|
+
</div>
|
936
|
+
|
937
|
+
</li>
|
938
|
+
|
939
|
+
<li>
|
940
|
+
|
941
|
+
<span class='name'>whitelist</span>
|
942
|
+
|
943
|
+
|
944
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
945
|
+
|
946
|
+
|
947
|
+
|
948
|
+
—
|
949
|
+
<div class='inline'><p>The list of options to include. By default all options are included.</p>
|
950
|
+
</div>
|
951
|
+
|
952
|
+
</li>
|
953
|
+
|
954
|
+
</ul>
|
955
|
+
|
956
|
+
<p class="tag_title">Returns:</p>
|
957
|
+
<ul class="return">
|
958
|
+
|
959
|
+
<li>
|
960
|
+
|
961
|
+
|
962
|
+
<span class='type'>(<tt>HashWithIndifferentAccess</tt>)</span>
|
963
|
+
|
964
|
+
|
965
|
+
|
966
|
+
—
|
967
|
+
<div class='inline'><p>The requested options.</p>
|
968
|
+
</div>
|
969
|
+
|
970
|
+
</li>
|
971
|
+
|
972
|
+
</ul>
|
973
|
+
|
974
|
+
</div><table class="source_code">
|
975
|
+
<tr>
|
976
|
+
<td>
|
977
|
+
<pre class="lines">
|
978
|
+
|
979
|
+
|
980
|
+
244
|
981
|
+
245
|
982
|
+
246
|
983
|
+
247
|
984
|
+
248
|
985
|
+
249</pre>
|
986
|
+
</td>
|
987
|
+
<td>
|
988
|
+
<pre class="code"><span class="info file"># File 'lib/mamertes/command.rb', line 244</span>
|
989
|
+
|
990
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_get_options'>get_options</span><span class='lparen'>(</span><span class='id identifier rubyid_unprovided'>unprovided</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_application'>application</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>application_</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_prefix'>prefix</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_whitelist'>whitelist</span><span class='rparen'>)</span>
|
991
|
+
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
992
|
+
<span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_get_options'>get_options</span><span class='lparen'>(</span><span class='id identifier rubyid_unprovided'>unprovided</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_application'>application</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_whitelist'>whitelist</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_application'>application</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_is_application?'>is_application?</span>
|
993
|
+
<span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span><span class='lparen'>(</span><span class='id identifier rubyid_get_current_options'>get_current_options</span><span class='lparen'>(</span><span class='id identifier rubyid_unprovided'>unprovided</span><span class='comma'>,</span> <span class='id identifier rubyid_prefix'>prefix</span><span class='comma'>,</span> <span class='id identifier rubyid_whitelist'>whitelist</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
994
|
+
<span class='id identifier rubyid_rv'>rv</span>
|
995
|
+
<span class='kw'>end</span></pre>
|
996
|
+
</td>
|
997
|
+
</tr>
|
998
|
+
</table>
|
999
|
+
</div>
|
1000
|
+
|
1001
|
+
<div class="method_details ">
|
1002
|
+
<h3 class="signature " id="has_commands?-instance_method">
|
1003
|
+
|
1004
|
+
- (<tt>Boolean</tt>) <strong>has_commands?</strong>
|
1005
|
+
|
1006
|
+
|
1007
|
+
|
1008
|
+
|
1009
|
+
|
1010
|
+
</h3><div class="docstring">
|
1011
|
+
<div class="discussion">
|
1012
|
+
<p>Check if this command has subcommands.</p>
|
1013
|
+
|
1014
|
+
|
1015
|
+
</div>
|
1016
|
+
</div>
|
1017
|
+
<div class="tags">
|
1018
|
+
|
1019
|
+
<p class="tag_title">Returns:</p>
|
1020
|
+
<ul class="return">
|
1021
|
+
|
1022
|
+
<li>
|
1023
|
+
|
1024
|
+
|
1025
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
1026
|
+
|
1027
|
+
|
1028
|
+
|
1029
|
+
—
|
1030
|
+
<div class='inline'><p><code>true</code> if this command has subcommands, <code>false</code> otherwise.</p>
|
1031
|
+
</div>
|
1032
|
+
|
1033
|
+
</li>
|
1034
|
+
|
1035
|
+
</ul>
|
1036
|
+
|
1037
|
+
</div><table class="source_code">
|
1038
|
+
<tr>
|
1039
|
+
<td>
|
1040
|
+
<pre class="lines">
|
1041
|
+
|
1042
|
+
|
1043
|
+
195
|
1044
|
+
196
|
1045
|
+
197</pre>
|
1046
|
+
</td>
|
1047
|
+
<td>
|
1048
|
+
<pre class="code"><span class="info file"># File 'lib/mamertes/command.rb', line 195</span>
|
1049
|
+
|
1050
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_has_commands?'>has_commands?</span>
|
1051
|
+
<span class='id identifier rubyid_commands'>commands</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>></span> <span class='int'>0</span>
|
1052
|
+
<span class='kw'>end</span></pre>
|
1053
|
+
</td>
|
1054
|
+
</tr>
|
1055
|
+
</table>
|
1056
|
+
</div>
|
1057
|
+
|
1058
|
+
<div class="method_details ">
|
1059
|
+
<h3 class="signature " id="has_options?-instance_method">
|
1060
|
+
|
1061
|
+
- (<tt>Boolean</tt>) <strong>has_options?</strong>
|
1062
|
+
|
1063
|
+
|
1064
|
+
|
1065
|
+
|
1066
|
+
|
1067
|
+
</h3><div class="docstring">
|
1068
|
+
<div class="discussion">
|
1069
|
+
<p>Check if this command has options.</p>
|
1070
|
+
|
1071
|
+
|
1072
|
+
</div>
|
1073
|
+
</div>
|
1074
|
+
<div class="tags">
|
1075
|
+
|
1076
|
+
<p class="tag_title">Returns:</p>
|
1077
|
+
<ul class="return">
|
1078
|
+
|
1079
|
+
<li>
|
1080
|
+
|
1081
|
+
|
1082
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
1083
|
+
|
1084
|
+
|
1085
|
+
|
1086
|
+
—
|
1087
|
+
<div class='inline'><p><code>true</code> if this command has options, <code>false</code> otherwise.</p>
|
1088
|
+
</div>
|
1089
|
+
|
1090
|
+
</li>
|
1091
|
+
|
1092
|
+
</ul>
|
1093
|
+
|
1094
|
+
</div><table class="source_code">
|
1095
|
+
<tr>
|
1096
|
+
<td>
|
1097
|
+
<pre class="lines">
|
1098
|
+
|
1099
|
+
|
1100
|
+
215
|
1101
|
+
216
|
1102
|
+
217</pre>
|
1103
|
+
</td>
|
1104
|
+
<td>
|
1105
|
+
<pre class="code"><span class="info file"># File 'lib/mamertes/command.rb', line 215</span>
|
1106
|
+
|
1107
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_has_options?'>has_options?</span>
|
1108
|
+
<span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>></span> <span class='int'>0</span>
|
1109
|
+
<span class='kw'>end</span></pre>
|
1110
|
+
</td>
|
1111
|
+
</tr>
|
1112
|
+
</table>
|
1113
|
+
</div>
|
1114
|
+
|
1115
|
+
<div class="method_details ">
|
1116
|
+
<h3 class="signature " id="option-instance_method">
|
1117
|
+
|
1118
|
+
- (<tt><span class='object_link'><a href="../Option.html" title="Mamertes::Option (class)">Option</a></span></tt>) <strong>option</strong>(name, forms = [], options = {}, &action)
|
1119
|
+
|
1120
|
+
|
1121
|
+
|
1122
|
+
|
1123
|
+
|
1124
|
+
</h3><div class="docstring">
|
1125
|
+
<div class="discussion">
|
1126
|
+
<p>Adds a new option to this command.</p>
|
1127
|
+
|
1128
|
+
|
1129
|
+
</div>
|
1130
|
+
</div>
|
1131
|
+
<div class="tags">
|
1132
|
+
<p class="tag_title">Parameters:</p>
|
1133
|
+
<ul class="param">
|
1134
|
+
|
1135
|
+
<li>
|
1136
|
+
|
1137
|
+
<span class='name'>name</span>
|
1138
|
+
|
1139
|
+
|
1140
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1141
|
+
|
1142
|
+
|
1143
|
+
|
1144
|
+
—
|
1145
|
+
<div class='inline'><p>The name of the option. Must be unique.</p>
|
1146
|
+
</div>
|
1147
|
+
|
1148
|
+
</li>
|
1149
|
+
|
1150
|
+
<li>
|
1151
|
+
|
1152
|
+
<span class='name'>forms</span>
|
1153
|
+
|
1154
|
+
|
1155
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
1156
|
+
|
1157
|
+
|
1158
|
+
<em class="default">(defaults to: <tt>[]</tt>)</em>
|
1159
|
+
|
1160
|
+
|
1161
|
+
—
|
1162
|
+
<div class='inline'><p>An array of short and long forms for this option.</p>
|
1163
|
+
</div>
|
1164
|
+
|
1165
|
+
</li>
|
1166
|
+
|
1167
|
+
<li>
|
1168
|
+
|
1169
|
+
<span class='name'>options</span>
|
1170
|
+
|
1171
|
+
|
1172
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1173
|
+
|
1174
|
+
|
1175
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
1176
|
+
|
1177
|
+
|
1178
|
+
—
|
1179
|
+
<div class='inline'><p>The settings for the option.</p>
|
1180
|
+
</div>
|
1181
|
+
|
1182
|
+
</li>
|
1183
|
+
|
1184
|
+
<li>
|
1185
|
+
|
1186
|
+
<span class='name'>action</span>
|
1187
|
+
|
1188
|
+
|
1189
|
+
<span class='type'>(<tt>Proc</tt>)</span>
|
1190
|
+
|
1191
|
+
|
1192
|
+
|
1193
|
+
—
|
1194
|
+
<div class='inline'><p>An optional action to pass to the option.</p>
|
1195
|
+
</div>
|
1196
|
+
|
1197
|
+
</li>
|
1198
|
+
|
1199
|
+
</ul>
|
1200
|
+
|
1201
|
+
<p class="tag_title">Returns:</p>
|
1202
|
+
<ul class="return">
|
1203
|
+
|
1204
|
+
<li>
|
1205
|
+
|
1206
|
+
|
1207
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Option.html" title="Mamertes::Option (class)">Option</a></span></tt>)</span>
|
1208
|
+
|
1209
|
+
|
1210
|
+
|
1211
|
+
—
|
1212
|
+
<div class='inline'><p>The newly added option.</p>
|
1213
|
+
</div>
|
1214
|
+
|
1215
|
+
</li>
|
1216
|
+
|
1217
|
+
</ul>
|
1218
|
+
|
1219
|
+
<p class="tag_title">See Also:</p>
|
1220
|
+
<ul class="see">
|
1221
|
+
|
1222
|
+
<li><span class='object_link'><a href="../Option.html#initialize-instance_method" title="Mamertes::Option#initialize (method)">Option#initialize</a></span></li>
|
1223
|
+
|
1224
|
+
</ul>
|
1225
|
+
|
1226
|
+
</div><table class="source_code">
|
1227
|
+
<tr>
|
1228
|
+
<td>
|
1229
|
+
<pre class="lines">
|
1230
|
+
|
1231
|
+
|
1232
|
+
160
|
1233
|
+
161
|
1234
|
+
162
|
1235
|
+
163
|
1236
|
+
164
|
1237
|
+
165
|
1238
|
+
166
|
1239
|
+
167
|
1240
|
+
168
|
1241
|
+
169
|
1242
|
+
170
|
1243
|
+
171
|
1244
|
+
172
|
1245
|
+
173
|
1246
|
+
174
|
1247
|
+
175
|
1248
|
+
176</pre>
|
1249
|
+
</td>
|
1250
|
+
<td>
|
1251
|
+
<pre class="code"><span class="info file"># File 'lib/mamertes/command.rb', line 160</span>
|
1252
|
+
|
1253
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_option'>option</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_forms'>forms</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
|
1254
|
+
<span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
|
1255
|
+
<span class='ivar'>@options</span> <span class='op'>||=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
1256
|
+
|
1257
|
+
<span class='kw'>if</span> <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='kw'>then</span>
|
1258
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_is_application?'>is_application?</span> <span class='kw'>then</span>
|
1259
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Mamertes</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:duplicate_option</span><span class='comma'>,</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_existing_option_global'>existing_option_global</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
1260
|
+
<span class='kw'>else</span>
|
1261
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Mamertes</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='symbol'>:duplicate_option</span><span class='comma'>,</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_existing_option'>existing_option</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_full_name'>full_name</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
1262
|
+
<span class='kw'>end</span>
|
1263
|
+
<span class='kw'>end</span>
|
1264
|
+
|
1265
|
+
<span class='id identifier rubyid_option'>option</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>Mamertes</span><span class='op'>::</span><span class='const'>Option</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_forms'>forms</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
|
1266
|
+
<span class='id identifier rubyid_option'>option</span><span class='period'>.</span><span class='id identifier rubyid_parent'>parent</span> <span class='op'>=</span> <span class='kw'>self</span>
|
1267
|
+
<span class='ivar'>@options</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_option'>option</span>
|
1268
|
+
<span class='id identifier rubyid_option'>option</span>
|
1269
|
+
<span class='kw'>end</span></pre>
|
1270
|
+
</td>
|
1271
|
+
</tr>
|
1272
|
+
</table>
|
1273
|
+
</div>
|
1274
|
+
|
1275
|
+
</div>
|
1276
|
+
|
1277
|
+
</div>
|
1278
|
+
|
1279
|
+
<div id="footer">
|
1280
|
+
Generated on Sat Aug 10 16:23:09 2013 by
|
1281
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1282
|
+
0.8.6.2 (ruby-1.9.3).
|
1283
|
+
</div>
|
1284
|
+
|
1285
|
+
</body>
|
1286
|
+
</html>
|