como 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.rdoc +7 -0
- data/doc/Como/ArgsParseState.html +52 -52
- data/doc/Como/ComoCommon.html +128 -33
- data/doc/Como/MainOpt.html +52 -55
- data/doc/Como/Opt/ErrorWithData.html +15 -15
- data/doc/Como/Opt/InvalidOption.html +1 -1
- data/doc/Como/Opt/MissingArgument.html +1 -1
- data/doc/Como/Opt.html +1211 -821
- data/doc/Como/RuleCheck.html +143 -92
- data/doc/Como/RuleDisplay.html +96 -92
- data/doc/Como/Spec.html +636 -273
- data/doc/Como.html +56 -36
- data/doc/_index.html +1 -1
- data/doc/file.CHANGELOG.html +12 -2
- data/doc/file.README.html +1 -1
- data/doc/index.html +1 -1
- data/doc/method_list.html +113 -71
- data/doc/top-level-namespace.html +1 -1
- data/lib/como.rb +217 -102
- data/lib/version.rb +2 -7
- metadata +60 -67
- data/Rakefile +0 -59
data/doc/Como.html
CHANGED
@@ -128,7 +128,7 @@ usage.</p>
|
|
128
128
|
|
129
129
|
<p>First Como is required and Como module is included.</p>
|
130
130
|
|
131
|
-
<p
|
131
|
+
<p><span class='object_link'><a href="Como/Spec.html#command-class_method" title="Como::Spec.command (method)">Spec.command</a></span> method takes 4 arguments:</p>
|
132
132
|
<dl class="rdoc-list"><dt>progname</dt>
|
133
133
|
<dd>
|
134
134
|
<p>Name of the program (or command).</p>
|
@@ -166,8 +166,8 @@ option value is returned by:</p>
|
|
166
166
|
<p>The option name also doubles as long option format, i.e. one could use
|
167
167
|
"--file <filename>" on the command line.</p>
|
168
168
|
|
169
|
-
<p>Existence of optional options can be tested using the "given" method.
|
170
|
-
example</p>
|
169
|
+
<p>Existence of optional options can be tested using the <span class='object_link'><a href="Como/Opt.html#given-instance_method" title="Como::Opt#given (method)">Opt#given</a></span> method.
|
170
|
+
For example</p>
|
171
171
|
|
172
172
|
<pre class="code ruby"><code class="ruby"><span class='const'>Opt</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>debug</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_given'>given</span></code></pre>
|
173
173
|
|
@@ -269,13 +269,13 @@ have their own command line switches and options.</p>
|
|
269
269
|
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>rm</span><span class='tstring_end'>'</span></span><span class='semicolon'>;</span> <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> Removing file \"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_subcmd'>subcmd</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>file</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='rbrace'>}</span><span class='tstring_content'>\"...</span><span class='tstring_end'>"</span></span>
|
270
270
|
<span class='kw'>end</span></code></pre>
|
271
271
|
|
272
|
-
<p
|
272
|
+
<p><span class='object_link'><a href="Como/Spec.html#program-class_method" title="Como::Spec.program (method)">Spec.program</a></span> method defines a program (command) with subcommands. The
|
273
273
|
author and date are provided as parameters, and the program and subcommand
|
274
274
|
options are defined in block.</p>
|
275
275
|
|
276
|
-
<p>The first "command" (or "subcmd") method call defines the main
|
277
|
-
("Opt.main") which represents the program. It has two "subcmd"
|
278
|
-
("add" and "rm").</p>
|
276
|
+
<p>The first <span class='object_link'><a href="Como/Spec.html#command-instance_method" title="Como::Spec#command (method)">Spec#command</a></span> (or <span class='object_link'><a href="Como/Spec.html#subcmd-instance_method" title="Como::Spec#subcmd (method)">Spec#subcmd</a></span>) method call defines the main
|
277
|
+
command (<span class='object_link'><a href="Como/Opt.html#main-class_method" title="Como::Opt.main (method)">Opt.main</a></span>) which represents the program. It has two "subcmd"
|
278
|
+
options ("add" and "rm").</p>
|
279
279
|
|
280
280
|
<p>The rest of the "subcmd" methods define subcommands for the parent command.
|
281
281
|
This example includes one subcommand level, but multiple levels are
|
@@ -294,17 +294,17 @@ definition allows "add" to have either the "-fo" option defined or
|
|
294
294
|
|
295
295
|
<pre class="code ruby"><code class="ruby"><span class='const'>Opt</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>como_subcmd</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span></code></pre>
|
296
296
|
|
297
|
-
<p>The subcommands can be referenced through "Opt.main" (etc.)</p>
|
297
|
+
<p>The subcommands can be referenced through <span class='object_link'><a href="Como/Opt.html#main-class_method" title="Como::Opt.main (method)">Opt.main</a></span> (etc.)</p>
|
298
298
|
|
299
299
|
<pre class="code ruby"><code class="ruby"><span class='const'>Opt</span><span class='period'>.</span><span class='id identifier rubyid_main'>main</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>add</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span>
|
300
300
|
<span class='const'>Opt</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>como_subcmd</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>add</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span></code></pre>
|
301
301
|
|
302
|
-
<p>or directly from "Opt" if subcommand names do not collide:</p>
|
302
|
+
<p>or directly from <span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span> if subcommand names do not collide:</p>
|
303
303
|
|
304
304
|
<pre class="code ruby"><code class="ruby"><span class='const'>Opt</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>add</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span></code></pre>
|
305
305
|
|
306
|
-
<p>The given subcommand can be accessed with "givenSubcmd" method from
|
307
|
-
parent command.</p>
|
306
|
+
<p>The given subcommand can be accessed with <span class='object_link'><a href="Como/Opt.html#givenSubcmd-instance_method" title="Como::Opt#givenSubcmd (method)">Opt#givenSubcmd</a></span> method from
|
307
|
+
each parent command.</p>
|
308
308
|
|
309
309
|
<h3>Subcommand example executions</h3>
|
310
310
|
|
@@ -389,7 +389,7 @@ command line parsing. It is used to:</p>
|
|
389
389
|
<p>Mandatory multiple argument option (one or many). Option values in array.</p>
|
390
390
|
</dd><dt>:opt_single</dt>
|
391
391
|
<dd>
|
392
|
-
<p>Optional single argument option.</p>
|
392
|
+
<p>Optional single argument option. Value is nil when option is not given.</p>
|
393
393
|
</dd><dt>:opt_multi</dt>
|
394
394
|
<dd>
|
395
395
|
<p>Optional multiple argument option (one or many). Option values in array.</p>
|
@@ -404,7 +404,7 @@ left out, since only the document string is used. Default option is
|
|
404
404
|
referred with ":default" or "nil".</p>
|
405
405
|
</dd><dt>:exclusive</dt>
|
406
406
|
<dd>
|
407
|
-
<p>Option that does not
|
407
|
+
<p>Option that does not co-exist with other options. :exclusive can have
|
408
408
|
arguments as with :opt_any, however :exclusive is documented like :switch.</p>
|
409
409
|
</dd><dt>:silent</dt>
|
410
410
|
<dd>
|
@@ -435,8 +435,8 @@ can be used to terminate the argument list. For example:</p>
|
|
435
435
|
<p>Option behavior can be controlled with several configuration options.</p>
|
436
436
|
|
437
437
|
<p>The configuration options are provided in a Hash. These are the passed as
|
438
|
-
the last regular parameter for both "Spec.command" and "Spec.program"
|
439
|
-
methods. Setting the configuration at "Spec.program" will propagate the
|
438
|
+
the last regular parameter for both <span class='object_link'><a href="Como/Spec.html#command-class_method" title="Como::Spec.command (method)">Spec.command</a></span> and <span class='object_link'><a href="Como/Spec.html#program-class_method" title="Como::Spec.program (method)">Spec.program</a></span>
|
439
|
+
methods. Setting the configuration at <span class='object_link'><a href="Como/Spec.html#program-class_method" title="Como::Spec.program (method)">Spec.program</a></span> will propagate the
|
440
440
|
config options to all the subcommands as well. Configuration can be given
|
441
441
|
to each subcommand separately to override the inherited config values.
|
442
442
|
Subcommand settings are not inherited, but apply only in the subcommand.</p>
|
@@ -484,9 +484,9 @@ whether they are specified on the command line using:</p>
|
|
484
484
|
|
485
485
|
<pre class="code ruby"><code class="ruby"><span class='const'>Opt</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>name</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_given'>given</span></code></pre>
|
486
486
|
|
487
|
-
<p>The "given" method takes optionally a block argument. When block
|
488
|
-
is used, the block is supplied with option value and the block is
|
489
|
-
if the option has been set (See: Opt#given).</p>
|
487
|
+
<p>The <span class='object_link'><a href="Como/Opt.html#given-instance_method" title="Como::Opt#given (method)">Opt#given</a></span> method takes optionally a block argument. When block
|
488
|
+
argument is used, the block is supplied with option value and the block is
|
489
|
+
executed if the option has been set (See: <span class='object_link'><a href="Como/Opt.html#given-instance_method" title="Como::Opt#given (method)">Opt#given</a></span>).</p>
|
490
490
|
|
491
491
|
<p>Provided value is returned by:</p>
|
492
492
|
|
@@ -540,7 +540,7 @@ example with option:</p>
|
|
540
540
|
|
541
541
|
<h2>Subcommand options</h2>
|
542
542
|
|
543
|
-
<p>The given subcommand for the parent command is return by "givenSubcmd"
|
543
|
+
<p>The given subcommand for the parent command is return by <span class='object_link'><a href="Como/Opt.html#givenSubcmd-instance_method" title="Como::Opt#givenSubcmd (method)">Opt#givenSubcmd</a></span>.
|
544
544
|
Commonly the program creator should just check directly which subcommand
|
545
545
|
has been selected and check for any subcommand options set. For example:</p>
|
546
546
|
|
@@ -550,7 +550,7 @@ has been selected and check for any subcommand options set. For example:</p>
|
|
550
550
|
<h2>Program external options</h2>
|
551
551
|
|
552
552
|
<p>If the user gives the "--" option (double-dash), the arguments after that
|
553
|
-
option are returned as an Array with "Opt.external"
|
553
|
+
option are returned as an Array with <span class='object_link'><a href="Como/Opt.html#external-class_method" title="Como::Opt.external (method)">Opt.external</a></span>.</p>
|
554
554
|
|
555
555
|
<h1>Option combination checks</h1>
|
556
556
|
|
@@ -590,8 +590,8 @@ exclusive.</p>
|
|
590
590
|
|
591
591
|
<h1>Customization</h1>
|
592
592
|
|
593
|
-
<p>A user specific customization file can be referenced through the
|
594
|
-
environment variable. If environment variable "COMO" is defined, the
|
593
|
+
<p>A Como user specific customization file can be referenced through the
|
594
|
+
"COMO" environment variable. If environment variable "COMO" is defined, the
|
595
595
|
referenced file is read in as Ruby file as a last phase when Como is loaded
|
596
596
|
from the program (require). Proposed naming convention for the
|
597
597
|
customization is:</p>
|
@@ -601,9 +601,9 @@ customization is:</p>
|
|
601
601
|
<p>User can define a pre and a post action hook in the file.</p>
|
602
602
|
|
603
603
|
<p>The pre-hook can be used for example to change the Como config defaults. It
|
604
|
-
is run before the body of "Spec.command" or "Spec.program" is executed. It
|
605
|
-
is passed all the parameters that has been passed to "Spec.command" or
|
606
|
-
"Spec.program"
|
604
|
+
is run before the body of <span class='object_link'><a href="Como/Spec.html#command-class_method" title="Como::Spec.command (method)">Spec.command</a></span> or <span class='object_link'><a href="Como/Spec.html#program-class_method" title="Como::Spec.program (method)">Spec.program</a></span> is executed. It
|
605
|
+
is passed all the parameters that has been passed to <span class='object_link'><a href="Como/Spec.html#command-class_method" title="Como::Spec.command (method)">Spec.command</a></span> or
|
606
|
+
<span class='object_link'><a href="Como/Spec.html#program-class_method" title="Como::Spec.program (method)">Spec.program</a></span>, only collected into a Hash. The Hash keys are method
|
607
607
|
parameter names as symbols.</p>
|
608
608
|
|
609
609
|
<p>Example:</p>
|
@@ -625,7 +625,15 @@ parameter names as symbols.</p>
|
|
625
625
|
<span class='kw'>end</span></code></pre>
|
626
626
|
|
627
627
|
<p>There is no predefined use cases for post-hook. Post-hook is passed the
|
628
|
-
Opt.main as parameter.</p>
|
628
|
+
<span class='object_link'><a href="Como/Opt.html#main-class_method" title="Como::Opt.main (method)">Opt.main</a></span> as parameter.</p>
|
629
|
+
|
630
|
+
<p><span class='object_link'><a href="Como/Spec.html#program-class_method" title="Como::Spec.program (method)">Spec.program</a></span> and <span class='object_link'><a href="Como/Spec.html#command-class_method" title="Como::Spec.command (method)">Spec.command</a></span> both process and check options in one
|
631
|
+
pass. Como user can separate the definition and checking phase. Definition
|
632
|
+
phase is performed by executing <span class='object_link'><a href="Como/Spec.html#defineProgram-class_method" title="Como::Spec.defineProgram (method)">Spec.defineProgram</a></span> or
|
633
|
+
<span class='object_link'><a href="Como/Spec.html#defineCommand-class_method" title="Como::Spec.defineCommand (method)">Spec.defineCommand</a></span>. After definition phase the user can for example
|
634
|
+
programmatically add new subcommands or options, in addition to existing
|
635
|
+
options. When the subcommands and options are complete, <span class='object_link'><a href="Como/Spec.html#execute-class_method" title="Como::Spec.execute (method)">Spec.execute</a></span>
|
636
|
+
should be called to perform options checking.</p>
|
629
637
|
|
630
638
|
<p>If the provided customization facilities are not satisfactory, changes can
|
631
639
|
be implemented simply by overloading the existing functions. Some knowledge
|
@@ -652,6 +660,18 @@ of the internal workings of Como is required though.</p>
|
|
652
660
|
|
653
661
|
</p>
|
654
662
|
|
663
|
+
<h2>Constant Summary</h2>
|
664
|
+
|
665
|
+
<dl class="constants">
|
666
|
+
|
667
|
+
<dt id="VERSION-constant" class="">VERSION =
|
668
|
+
|
669
|
+
</dt>
|
670
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>0.1.4</span><span class='tstring_end'>"</span></span></pre></dd>
|
671
|
+
|
672
|
+
</dl>
|
673
|
+
|
674
|
+
|
655
675
|
|
656
676
|
|
657
677
|
|
@@ -771,12 +791,12 @@ of the internal workings of Como is required though.</p>
|
|
771
791
|
<pre class="lines">
|
772
792
|
|
773
793
|
|
774
|
-
|
775
|
-
|
776
|
-
|
794
|
+
520
|
795
|
+
521
|
796
|
+
522</pre>
|
777
797
|
</td>
|
778
798
|
<td>
|
779
|
-
<pre class="code"><span class="info file"># File 'lib/como.rb', line
|
799
|
+
<pre class="code"><span class="info file"># File 'lib/como.rb', line 520</span>
|
780
800
|
|
781
801
|
<span class='kw'>def</span> <span class='const'>Como</span><span class='period'>.</span><span class='id identifier rubyid_postHook'>postHook</span><span class='lparen'>(</span> <span class='op'>&</span><span class='id identifier rubyid_code'>code</span> <span class='rparen'>)</span>
|
782
802
|
<span class='const'>ComoCommon</span><span class='period'>.</span><span class='id identifier rubyid_setHook'>setHook</span><span class='lparen'>(</span> <span class='symbol'>:postHook</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_code'>code</span> <span class='rparen'>)</span>
|
@@ -812,12 +832,12 @@ of the internal workings of Como is required though.</p>
|
|
812
832
|
<pre class="lines">
|
813
833
|
|
814
834
|
|
815
|
-
|
816
|
-
|
817
|
-
|
835
|
+
514
|
836
|
+
515
|
837
|
+
516</pre>
|
818
838
|
</td>
|
819
839
|
<td>
|
820
|
-
<pre class="code"><span class="info file"># File 'lib/como.rb', line
|
840
|
+
<pre class="code"><span class="info file"># File 'lib/como.rb', line 514</span>
|
821
841
|
|
822
842
|
<span class='kw'>def</span> <span class='const'>Como</span><span class='period'>.</span><span class='id identifier rubyid_preHook'>preHook</span><span class='lparen'>(</span> <span class='op'>&</span><span class='id identifier rubyid_code'>code</span> <span class='rparen'>)</span>
|
823
843
|
<span class='const'>ComoCommon</span><span class='period'>.</span><span class='id identifier rubyid_setHook'>setHook</span><span class='lparen'>(</span> <span class='symbol'>:preHook</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_code'>code</span> <span class='rparen'>)</span>
|
@@ -850,7 +870,7 @@ of the internal workings of Como is required though.</p>
|
|
850
870
|
<pre class="code"><span class="info file"># File 'lib/version.rb', line 3</span>
|
851
871
|
|
852
872
|
<span class='kw'>def</span> <span class='const'>Como</span><span class='period'>.</span><span class='id identifier rubyid_version'>version</span>
|
853
|
-
<span class='const'>
|
873
|
+
<span class='const'>Como</span><span class='op'>::</span><span class='const'>VERSION</span>
|
854
874
|
<span class='kw'>end</span></pre>
|
855
875
|
</td>
|
856
876
|
</tr>
|
@@ -862,7 +882,7 @@ of the internal workings of Como is required though.</p>
|
|
862
882
|
</div>
|
863
883
|
|
864
884
|
<div id="footer">
|
865
|
-
Generated on
|
885
|
+
Generated on Sat Nov 22 10:05:15 2014 by
|
866
886
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
867
887
|
0.8.6.1 (ruby-1.9.3).
|
868
888
|
</div>
|
data/doc/_index.html
CHANGED
@@ -233,7 +233,7 @@
|
|
233
233
|
</div>
|
234
234
|
|
235
235
|
<div id="footer">
|
236
|
-
Generated on
|
236
|
+
Generated on Sat Nov 22 10:05:15 2014 by
|
237
237
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
238
238
|
0.8.6.1 (ruby-1.9.3).
|
239
239
|
</div>
|
data/doc/file.CHANGELOG.html
CHANGED
@@ -63,7 +63,17 @@
|
|
63
63
|
|
64
64
|
<div id="content"><div id='filecontents'>
|
65
65
|
<h1>Version history</h1>
|
66
|
-
<dl class="rdoc-list"><dt>0.1.
|
66
|
+
<dl class="rdoc-list"><dt>0.1.4</dt>
|
67
|
+
<dd>
|
68
|
+
<p>Documentation improvements (links to methods). Fix to Opt#apply return
|
69
|
+
value when type is :switch. Opt#fatal added for user error reporting
|
70
|
+
towards command line user. Non-existing options for option with multiple
|
71
|
+
values defaults</p>
|
72
|
+
|
73
|
+
<pre class="code ruby"><code class="ruby">to an empty array.</code></pre>
|
74
|
+
|
75
|
+
<p>Possibility to separate option definition and execution.</p>
|
76
|
+
</dd><dt>0.1.3</dt>
|
67
77
|
<dd>
|
68
78
|
<p>Customization through COMO env variable and hooks. Version information
|
69
79
|
returned programmatically with Como.version. "command" is aliased to
|
@@ -98,7 +108,7 @@ settings, i.e. the Opt#params method added.</p>
|
|
98
108
|
</div></div>
|
99
109
|
|
100
110
|
<div id="footer">
|
101
|
-
Generated on
|
111
|
+
Generated on Sat Nov 22 10:05:15 2014 by
|
102
112
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
103
113
|
0.8.6.1 (ruby-1.9.3).
|
104
114
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -85,7 +85,7 @@ used.</p>
|
|
85
85
|
</div></div>
|
86
86
|
|
87
87
|
<div id="footer">
|
88
|
-
Generated on
|
88
|
+
Generated on Sat Nov 22 10:05:15 2014 by
|
89
89
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
90
90
|
0.8.6.1 (ruby-1.9.3).
|
91
91
|
</div>
|
data/doc/index.html
CHANGED
@@ -85,7 +85,7 @@ used.</p>
|
|
85
85
|
</div></div>
|
86
86
|
|
87
87
|
<div id="footer">
|
88
|
-
Generated on
|
88
|
+
Generated on Sat Nov 22 10:05:15 2014 by
|
89
89
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
90
90
|
0.8.6.1 (ruby-1.9.3).
|
91
91
|
</div>
|