<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title> Module: Como — Documentation by YARD 0.9.16 </title> <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" /> <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" /> <script type="text/javascript" charset="utf-8"> pathId = "Como"; relpath = ''; </script> <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script> <script type="text/javascript" charset="utf-8" src="js/app.js"></script> </head> <body> <div class="nav_wrap"> <iframe id="nav" src="class_list.html?1"></iframe> <div id="resizer"></div> </div> <div id="main" tabindex="-1"> <div id="header"> <div id="menu"> <a href="_index.html">Index (C)</a> » <span class="title">Como</span> </div> <div id="search"> <a class="full_list_link" id="class_list_link" href="class_list.html"> <svg width="24" height="24"> <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect> <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect> <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect> </svg> </a> </div> <div class="clear"></div> </div> <div id="content"><h1>Module: Como </h1> <div class="box_info"> <dl> <dt>Defined in:</dt> <dd>lib/como.rb<span class="defines">,<br /> lib/version.rb</span> </dd> </dl> </div> <h2>Overview</h2><div class="docstring"> <div class="discussion"> <p>Como</p> <h1 id="label-Introduction">Introduction</h1> <p>Como provides low manifest command line option parsing and deployment. The command line options are described in compact table format and option values are stored to conveniently named properties. Como builds command usage information based on the option table (+ generic program info) and displays it automatically if necessary. Como supports also subcommands and checking for option combinations using a simple DSL.</p> <h1 id="label-Usage+Examples">Usage Examples</h1> <p>Two simple examples are presented in this section. First one includes a straight forward command definition and the second is a bit more complicated with subcommand feature in use.</p> <h2 id="label-Simple+example">Simple example</h2> <p>Below is a small example program (“como_simple”) that demonstrates typical usage.</p> <h3 id="label-Program+listing">Program listing</h3> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>como</span><span class='tstring_end'>"</span></span> <span class='id identifier rubyid_include'>include</span> <span class='const'>Como</span> <span class='comment'># Define command line arguments: </span><span class='const'><span class='object_link'><a href="Como/Spec.html" title="Como::Spec (class)">Spec</a></span></span><span class='period'>.</span><span class='id identifier rubyid_command'><span class='object_link'><a href="Como/Spec.html#command-class_method" title="Como::Spec.command (method)">command</a></span></span><span class='lparen'>(</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>como_simple</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Programmer</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2013</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='lbracket'>[</span> <span class='lbracket'>[</span> <span class='symbol'>:single</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>file</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>-f</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>File argument.</span><span class='tstring_end'>"</span></span> <span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbracket'>[</span> <span class='symbol'>:switch</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>debug</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>-d</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Enable debugging.</span><span class='tstring_end'>"</span></span> <span class='rbracket'>]</span><span class='comma'>,</span> <span class='rbracket'>]</span> <span class='rparen'>)</span> <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> File option: </span><span class='embexpr_beg'>#{</span><span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></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='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> Debugging selected!</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></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> <p>First Como is required and Como module is included.</p> <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> <dl class="rdoc-list label-list"><dt>progname <dd> <p>Name of the program (or command).</p> </dd><dt>author <dd> <p>Author of the program.</p> </dd><dt>year <dd> <p>Year (or any date) for the program.</p> </dd><dt>option table <dd> <p>Description of the command options.</p> </dd></dl> <p>Each option table entry (row/sub-array) includes 4 fields and specifies one option:</p> <pre class="code ruby"><code class="ruby"><span class='lbracket'>[</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_mnemonic'>mnemonic</span><span class='comma'>,</span> <span class='id identifier rubyid_doc'>doc</span> <span class='rbracket'>]</span> </code></pre> <p>Two different types are present in the example:</p> <dl class="rdoc-list label-list"><dt>:single <dd> <p>Single means that the option requires one argument (and only one).</p> </dd><dt>:switch <dd> <p>Switch is an optional flag (default value is false).</p> </dd></dl> <p>Option name is used to reference the option value that user has given. The command line option values are stored automatically. For example the file option value is returned by:</p> <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></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> </code></pre> <p>The option name also doubles as long option format, i.e. one could use “–file <filename>” on the command line.</p> <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. For example</p> <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></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> <p>would return “true” if “-d” was given on the command line.</p> <p>Mnemonic is the short form option specification e.g. “-f”. If short form is replaced with “nil”, the long option format is only available.</p> <p>Doc includes documentation for the option. It is displayed when “help” (“-h”) option is given. Help option is added to the command automatically as default behavior.</p> <h3 id="label-Simple+example+executions">Simple example executions</h3> <p>Normal behavior would be achieved by executing:</p> <pre class="code ruby"><code class="ruby">shell> como_simple -f example -d </code></pre> <p>The program would execute with the following output:</p> <pre class="code ruby"><code class="ruby"><span class='const'>File</span> <span class='label'>option:</span> <span class='id identifier rubyid_example'>example</span> <span class='const'>Debugging</span> <span class='id identifier rubyid_selected!'>selected!</span> </code></pre> <p>Same output would be achieved with:</p> <pre class="code ruby"><code class="ruby">shell> como_simple --file example --debug </code></pre> <p>Since option name doubles as long option.</p> <p>Como includes certain “extra” behavior out-of-box. Required arguments are checked for existence and error is displayed if arguments are not given.</p> <p>For example given the command:</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_shell'>shell</span><span class='op'>></span> <span class='id identifier rubyid_como_simple'>como_simple</span> </code></pre> <p>The following is displayed on the screen:</p> <pre class="code ruby"><code class="ruby">como_simple error: Option "-f" missing for "como_simple"... como_simple -f <file> [-d] -f File argument. -d Enable debugging. Copyright (c) 2013 by Programmer </code></pre> <p>Missing option error is displayed since “file” is a mandatory option. The error message is followed by “usage” display (Usage Help). Documentation string is taken from the option specification to “usage” display.</p> <p>Given the command:</p> <pre class="code ruby"><code class="ruby">shell> como_simple -h </code></pre> <p>would display the same “usage” screen except without the error line.</p> <h2 id="label-Subcommand+example">Subcommand example</h2> <p>Subcmd example includes a program which has subcommands. Subcommands can have their own command line switches and options.</p> <h3 id="label-Program+listing">Program listing</h3> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>como</span><span class='tstring_end'>"</span></span> <span class='id identifier rubyid_include'>include</span> <span class='const'>Como</span> <span class='const'><span class='object_link'><a href="Como/Spec.html" title="Como::Spec (class)">Spec</a></span></span><span class='period'>.</span><span class='id identifier rubyid_program'><span class='object_link'><a href="Como/Spec.html#program-class_method" title="Como::Spec.program (method)">program</a></span></span><span class='lparen'>(</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Programmer</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2013</span><span class='tstring_end'>"</span></span> <span class='rparen'>)</span> <span class='kw'>do</span> <span class='id identifier rubyid_command'>command</span><span class='lparen'>(</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>como_subcmd</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='lbracket'>[</span> <span class='lbracket'>[</span> <span class='symbol'>:subcmd</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>add</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Add file.</span><span class='tstring_end'>"</span></span> <span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbracket'>[</span> <span class='symbol'>:subcmd</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>rm</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Remove file.</span><span class='tstring_end'>"</span></span> <span class='rbracket'>]</span><span class='comma'>,</span> <span class='rbracket'>]</span><span class='comma'>,</span> <span class='rparen'>)</span> <span class='id identifier rubyid_subcmd'>subcmd</span><span class='lparen'>(</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>add</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='lbracket'>[</span> <span class='lbracket'>[</span> <span class='symbol'>:switch</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>force</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>-fo</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Force operation.</span><span class='tstring_end'>"</span></span> <span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbracket'>[</span> <span class='symbol'>:opt_single</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>password</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>-p</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>User password.</span><span class='tstring_end'>"</span></span> <span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbracket'>[</span> <span class='symbol'>:opt_single</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>username</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>-u</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Username.</span><span class='tstring_end'>"</span></span> <span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbracket'>[</span> <span class='symbol'>:single</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>file</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>-f</span><span class='tstring_end'>"</span></span><span class='comma'>,</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='comma'>,</span> <span class='rbracket'>]</span> <span class='rparen'>)</span> <span class='id identifier rubyid_check'>check</span> <span class='kw'>do</span> <span class='id identifier rubyid_one'>one</span><span class='lparen'>(</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>-fo</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='id identifier rubyid_all'>all</span><span class='lparen'>(</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>password</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>username</span><span class='tstring_end'>'</span></span> <span class='rparen'>)</span> <span class='rparen'>)</span> <span class='kw'>end</span> <span class='id identifier rubyid_subcmd'>subcmd</span><span class='lparen'>(</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>rm</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='lbracket'>[</span> <span class='lbracket'>[</span> <span class='symbol'>:single</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>file</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>-f</span><span class='tstring_end'>"</span></span><span class='comma'>,</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='comma'>,</span> <span class='rbracket'>]</span> <span class='rparen'>)</span> <span class='kw'>end</span> <span class='id identifier rubyid_subcmd'>subcmd</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></span><span class='period'>.</span><span class='id identifier rubyid_main'><span class='object_link'><a href="Como/Opt.html#main-class_method" title="Como::Opt.main (method)">main</a></span></span><span class='period'>.</span><span class='id identifier rubyid_givenSubcmd'>givenSubcmd</span> <span class='kw'>case</span> <span class='id identifier rubyid_subcmd'>subcmd</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>add</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'> Adding 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='embexpr_end'>}</span><span class='tstring_content'>\"...</span><span class='tstring_end'>"</span></span> <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='embexpr_end'>}</span><span class='tstring_content'>\"...</span><span class='tstring_end'>"</span></span> <span class='kw'>end</span> </code></pre> <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 author and date are provided as parameters, and the program and subcommand options are defined in block.</p> <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 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” options (“add” and “rm”).</p> <p>The rest of the “subcmd” methods define subcommands for the parent command. This example includes one subcommand level, but multiple levels are allowed.</p> <p>The “check” (or “checkRule”) method defines option combination (<span class='object_link'><a href="Como/RuleCheck.html" title="Como::RuleCheck (class)">RuleCheck</a></span>) for the previous subcommand definition. In this case the definition allows “add” to have either the “-fo” option defined or “password” and “username” in combination.</p> <p>Main (root) commands can be referenced through</p> <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></span><span class='period'>.</span><span class='id identifier rubyid_main'><span class='object_link'><a href="Como/Opt.html#main-class_method" title="Como::Opt.main (method)">main</a></span></span> </code></pre> <p>or alternatively</p> <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></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> <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> <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></span><span class='period'>.</span><span class='id identifier rubyid_main'><span class='object_link'><a href="Como/Opt.html#main-class_method" title="Como::Opt.main (method)">main</a></span></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> <span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></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> <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> <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></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> <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 each parent command.</p> <h3 id="label-Subcommand+example+executions">Subcommand example executions</h3> <p>Normal behavior would be achieved by executing:</p> <pre class="code ruby"><code class="ruby">shell> como_subcmd add -fo -f example </code></pre> <p>The program would execute with the following output:</p> <pre class="code ruby"><code class="ruby">Adding file "example"... </code></pre> <p>The option combinations for “add” subcommand are automatically checked. Thus executing:</p> <pre class="code ruby"><code class="ruby">shell> como_subcmd add -f example </code></pre> <p>Would result to:</p> <pre class="code ruby"><code class="ruby">como_subcmd error: Option combination mismatch! Subcommand "add" usage: como_subcmd add [-fo] [-p <password>] [-u <username>] -f <file> -fo Force operation. -p User password. -u Username. -f File. Option Combinations: |--# One of: | |--<-fo> | |--# All of: | | |--<password> | | |--<username> </code></pre> <p>since the combination rule requires either “-fo”, or both “password” and “username”.</p> <p>Help is automatically provided on each command level, thus these are both valid.</p> <pre class="code ruby"><code class="ruby">shell> como_subcmd -h </code></pre> <p>and</p> <pre class="code ruby"><code class="ruby">shell> como_subcmd rm -h </code></pre> <h1 id="label-Option+specification">Option specification</h1> <h2 id="label-Overview">Overview</h2> <p>Option specification includes the minimum set of information required for command line parsing. It is used to:</p> <ul><li> <p>Parse the command line.</p> </li><li> <p>Check for wrong options and report.</p> </li><li> <p>Check for mandatory arguments and report.</p> </li><li> <p>Set the options given/non-given state.</p> </li><li> <p>Set the options value. Array/String for all except true/false for switches.</p> </li><li> <p>Generate Usage Help printout.</p> </li></ul> <h2 id="label-Option+types">Option types</h2> <p>The following types can be defined for the command line options:</p> <dl class="rdoc-list label-list"><dt>:subcmd <dd> <p>Subcmd option. Subcmd specific options are provided separately.</p> </dd><dt>:switch <dd> <p>Single switch option (no arguments).</p> </dd><dt>:single <dd> <p>Mandatory single argument option.</p> </dd><dt>:comp <dd> <p>Mandatory single argument option (multiple times). Option values in array.</p> </dd><dt>:multi <dd> <p>Mandatory multiple argument option (one or many). Option values in array.</p> </dd><dt>:opt_single <dd> <p>Optional single argument option. Value is nil when option is not given.</p> </dd><dt>:opt_comp <dd> <p>Optional single argument option (multiple times). Value is nil when option is not given.</p> </dd><dt>:opt_multi <dd> <p>Optional multiple argument option (one or many). Option values in array.</p> </dd><dt>:opt_any <dd> <p>Optional multiple argument option (also none accepted). Option values in array.</p> </dd><dt>:default <dd> <p>Default option (no switch associated). Name and option String values can be left out, since only the document string is used. Default option is referred with “:default” or “nil”.</p> </dd><dt>:exclusive <dd> <p>Option that does not co-exist with other options. :exclusive can have arguments as with :opt_any.</p> </dd><dt>:silent <dd> <p>Switch option that is not displayed as an option in Usage Help display.</p> </dd></dl> <p>Options use typically all the 4 option fields:</p> <pre class="code ruby"><code class="ruby"><span class='lbracket'>[</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_mnemonic'>mnemonic</span><span class='comma'>,</span> <span class='id identifier rubyid_doc'>doc</span> <span class='rbracket'>]</span> </code></pre> <p>“type” field is mandatory for all options.</p> <p>“name” field is also mandatory for all options. “mnemonic” can be left out, but then option accepts only long option format.</p> <p>“:default” uses only “doc” and “:subcmd” doesn't use the “mnemonic” field.</p> <p>“:multi”, “:opt_multi”, and “:opt_any” option arguments are terminated only when an option specifier is found. This can be a problem if “:default” option follows. There are two simple solutions to this issue. “:comp” option takes only one argument per given switch, and hence is not ambiguous towards “:default” option. Another possibility is to use a “:silent” option that can be used to terminate the argument list. For example:</p> <pre class="code ruby"><code class="ruby">[ :silent, "terminator", "-", "The terminator." ], </code></pre> <h2 id="label-Option+type+primitives">Option type primitives</h2> <p>Como converts option types into option type primitives. Option types are not completely orthogonal, but primitives are.</p> <p>Primitives:</p> <dl class="rdoc-list label-list"><dt>:none <dd> <p>No arguments (i.e. switch).</p> </dd><dt>:one <dd> <p>One argument.</p> </dd><dt>:many <dd> <p>More than one argument.</p> </dd><dt>:repeat <dd> <p>Option can be repeated.</p> </dd><dt>:opt <dd> <p>Optional argument(s).</p> </dd><dt>:default <dd> <p>Default option.</p> </dd><dt>:mutex <dd> <p>Mutually exclusive option.</p> </dd><dt>:hidden <dd> <p>Hidden option (no usage doc).</p> </dd></dl> <p>Types to primitives mapping:</p> <dl class="rdoc-list label-list"><dt>:switch <dd> <p>:none, :opt</p> </dd><dt>:single <dd> <p>:one</p> </dd><dt>:comp <dd> <p>:one, :repeat</p> </dd><dt>:multi <dd> <p>:one, :many, :repeat</p> </dd><dt>:opt_single <dd> <p>:one, :opt</p> </dd><dt>:opt_comp <dd> <p>:one, :repeat, :opt</p> </dd><dt>:opt_multi <dd> <p>:one, :many, :repeat, :opt</p> </dd><dt>:opt_any <dd> <p>:none, :one, :many, :repeat, :opt</p> </dd><dt>:default <dd> <p>:none, :one, :many, :opt, :default</p> </dd><dt>:exclusive <dd> <p>:none, :one, :many, :opt, :mutex</p> </dd><dt>:silent <dd> <p>:none, :opt, :hidden, :repeat</p> </dd></dl> <p>Primitives can be used in place of types if exotic options are needed. Instead of a single Symbol an Array of primitives are given for option type. Order of primitives is not significant.</p> <p>For example:</p> <pre class="code ruby"><code class="ruby">[ [ :none, :hidden, :opt ], "terminator", "-", "The terminator." ], </code></pre> <p>Como does not check the primitive combinations, thus care and consideration should be applied.</p> <h2 id="label-Option+specification+method+configuration">Option specification method configuration</h2> <p>Option behavior can be controlled with several configuration options.</p> <p>The configuration options are provided in a Hash. These are the passed as 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> 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 config options to all the subcommands as well. Configuration can be given to each subcommand separately to override the inherited config values. Subcommand settings are not inherited, but apply only in the subcommand.</p> <p>The usable configuration Hash keys:</p> <dl class="rdoc-list label-list"><dt>:autohelp <dd> <p>Add help option automatically (default: true). Custom help option can be provided and it can be made also visible to user.</p> </dd><dt>:rulehelp <dd> <p>Include RuleCheck help to Usage Help (default: false).</p> </dd><dt>:header <dd> <p>Header lines before standard usage printout.</p> </dd><dt>:footer <dd> <p>Footer lines after standard usage printout.</p> </dd><dt>:subcheck <dd> <p>Automatically check that a subcommand is provided (default: true).</p> </dd><dt>:check_missing <dd> <p>Check for missing arguments (default: true).</p> </dd><dt>:check_invalid <dd> <p>Error for unknown options (default: true).</p> </dd><dt>:tab <dd> <p>Tab stop column for option documentation (default: 12).</p> </dd><dt>:help_exit <dd> <p>Exit program if help displayed (default: true).</p> </dd><dt>:copyright <dd> <p>Display copyright/author in usage printout (default: true).</p> </dd></dl> <h1 id="label-Option+referencing">Option referencing</h1> <h2 id="label-Existence+and+values">Existence and values</h2> <p>Opt class includes the parsed option values. All options can be tested whether they are specified on the command line using:</p> <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></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> <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 argument is used, the block is supplied with option value and the block is 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> <p>Provided value is returned by:</p> <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></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_value'>value</span> </code></pre> <p>For “:switch” type it is true/false value and for the other types a String or an Array of Strings.</p> <p>If an option takes multiple arguments, the value for the option is an Array. The values can be iterated simply by:</p> <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>files</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='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_val'>val</span><span class='op'>|</span> <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_val'>val</span> <span class='kw'>end</span> </code></pre> <p>Short syntax for value referencing is performed with unary operator “~”. Thus</p> <pre class="code ruby"><code class="ruby"><span class='op'>~</span><span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>files</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> </code></pre> <p>is equal to</p> <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>files</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span> </code></pre> <p>With “:opt_any” type, the user should first check if the option was given:</p> <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>many_files_or_none</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> <p>Then check how many arguments where given:</p> <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>many_files_or_none</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='period'>.</span><span class='id identifier rubyid_length'>length</span> </code></pre> <p>And finally decide what to do.</p> <h2 id="label-Options+including+parameters">Options including parameters</h2> <p>Sometimes it is convenient for the program to use an option to include multiple parameter settings. These settings can be parsed and mapped to a Hash. Como performs automatic conversion to numeric values if possible. For example with option:</p> <pre class="code ruby"><code class="ruby">--set rounds=10 length=5 </code></pre> <p>Como can be used extract the parameter values with the “params” method:</p> <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>set</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_params'>params</span> </code></pre> <p>And a Hash is returned:</p> <pre class="code ruby"><code class="ruby"><span class='lbrace'>{</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>rounds</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>10</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>length</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>5</span> <span class='rbrace'>}</span> </code></pre> <h2 id="label-Subcommand+options">Subcommand options</h2> <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>. Commonly the program creator should just check directly which subcommand has been selected and check for any subcommand options set. For example:</p> <pre class="code ruby"><code class="ruby">if Opt['como_subcmd']['add'].given ... </code></pre> <h2 id="label-Program+external+options">Program external options</h2> <p>If the user gives the “–” option (double-dash), the arguments after that 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> <h1 id="label-Option+combination+checks">Option combination checks</h1> <p>Como provides a facility to create relations between options using RuleCheck DSL. This is needed since sometimes options have to be used in combination to make sense for the program. Also options might be mutually exclusive.</p> <p>The following rules can be used (in combination):</p> <dl class="rdoc-list label-list"><dt>all <dd> <p>All options in the list.</p> </dd><dt>one <dd> <p>One and only one from the list.</p> </dd><dt>any <dd> <p>At least one of the list is given.</p> </dd><dt>none <dd> <p>No options are required.</p> </dd><dt>inv <dd> <p>Logical negation for existence.</p> </dd><dt>incr <dd> <p>Incremental options in order i.e. have to have previous to have later.</p> </dd><dt>follow <dd> <p>Incremental options in order i.e. have to have all later if had first.</p> </dd><dt>meh <dd> <p>Dont care, always succeeds.</p> </dd></dl> <p>Examples can be found above.</p> <h1 id="label-Customization">Customization</h1> <p>A Como user specific customization file can be referenced through the “COMO” environment variable. If environment variable “COMO” is defined, the referenced file is read in as Ruby file as a last phase when Como is loaded from the program (require). Proposed naming convention for the customization is:</p> <pre class="code ruby"><code class="ruby">$HOME/.como </code></pre> <p>User can define a pre and a post action hook in the file.</p> <p>The pre-hook can be used for example to change the Como config defaults. It 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 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 <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 parameter names as symbols.</p> <p>Example:</p> <pre class="code ruby"><code class="ruby"><span class='comment'># Define pre parser hook for Como. </span><span class='const'>Como</span><span class='period'>.</span><span class='id identifier rubyid_preHook'><span class='object_link'><a href="#preHook-class_method" title="Como.preHook (method)">preHook</a></span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_args'>args</span><span class='op'>|</span> <span class='comment'># Get default config for options. </span> <span class='id identifier rubyid_config'>config</span> <span class='op'>=</span> <span class='const'>Como</span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configGet'><span class='object_link'><a href="Como/Opt.html#configGet-class_method" title="Como::Opt.configGet (method)">configGet</a></span></span> <span class='comment'># Disable 'copyright' lines from usage. </span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span> <span class='symbol'>:copyright</span> <span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>false</span> <span class='comment'># Test if "Spec.command" is the entry method (it has arg named "prog"). </span> <span class='kw'>if</span> <span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span> <span class='symbol'>:prog</span> <span class='rbracket'>]</span> <span class='comment'># Place a custom header for all programs. </span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span> <span class='symbol'>:header</span> <span class='rbracket'>]</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\nProgram \"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span> <span class='symbol'>:prog</span> <span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>\" is ...\n\n</span><span class='tstring_end'>"</span></span> <span class='kw'>end</span> <span class='kw'>end</span> </code></pre> <p>There is no predefined use cases for post-hook. Post-hook is passed the <span class='object_link'><a href="Como/Opt.html#main-class_method" title="Como::Opt.main (method)">Opt.main</a></span> as parameter.</p> <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 pass. Como user can separate the definition and checking phase. Definition 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 <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 programmatically add new subcommands or options, in addition to existing 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> should be called to perform options checking.</p> <p>If the provided customization facilities are not satisfactory, changes can be implemented simply by overloading the existing functions. Some knowledge of the internal workings of Como is required though.</p> <p>Como version is returned with:</p> <pre class="code ruby"><code class="ruby"><span class='const'>Como</span><span class='period'>.</span><span class='id identifier rubyid_version'><span class='object_link'><a href="#version-class_method" title="Como.version (method)">version</a></span></span> </code></pre> </div> </div> <div class="tags"> </div><h2>Defined Under Namespace</h2> <p class="children"> <strong class="classes">Classes:</strong> <span class='object_link'><a href="Como/ArgsParseState.html" title="Como::ArgsParseState (class)">ArgsParseState</a></span>, <span class='object_link'><a href="Como/ComoCommon.html" title="Como::ComoCommon (class)">ComoCommon</a></span>, <span class='object_link'><a href="Como/MainOpt.html" title="Como::MainOpt (class)">MainOpt</a></span>, <span class='object_link'><a href="Como/Opt.html" title="Como::Opt (class)">Opt</a></span>, <span class='object_link'><a href="Como/RuleCheck.html" title="Como::RuleCheck (class)">RuleCheck</a></span>, <span class='object_link'><a href="Como/RuleDisplay.html" title="Como::RuleDisplay (class)">RuleDisplay</a></span>, <span class='object_link'><a href="Como/Spec.html" title="Como::Spec (class)">Spec</a></span> </p> <h2> Constant Summary <small><a href="#" class="constants_summary_toggle">collapse</a></small> </h2> <dl class="constants"> <dt id="VERSION-constant" class="">VERSION = </dt> <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>0.2.4</span><span class='tstring_end'>"</span></span></pre></dd> </dl> <h2> Class Method Summary <small><a href="#" class="summary_toggle">collapse</a></small> </h2> <ul class="summary"> <li class="public "> <span class="summary_signature"> <a href="#postHook-class_method" title="postHook (class method)">.<strong>postHook</strong>(&code) ⇒ Object </a> </span> <span class="summary_desc"><div class='inline'> <p>Set “postHook” routine.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="#preHook-class_method" title="preHook (class method)">.<strong>preHook</strong>(&code) ⇒ Object </a> </span> <span class="summary_desc"><div class='inline'> <p>Set “preHook” routine.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="#version-class_method" title="version (class method)">.<strong>version</strong> ⇒ Object </a> </span> <span class="summary_desc"><div class='inline'></div></span> </li> </ul> <div id="class_method_details" class="method_details_list"> <h2>Class Method Details</h2> <div class="method_details first"> <h3 class="signature first" id="postHook-class_method"> .<strong>postHook</strong>(&code) ⇒ <tt>Object</tt> </h3><div class="docstring"> <div class="discussion"> <p>Set “postHook” routine.</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 569 570 571</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/como.rb', line 569</span> <span class='kw'>def</span> <span class='const'><span class='object_link'><a href="" title="Como (module)">Como</a></span></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> <span class='const'><span class='object_link'><a href="Como/ComoCommon.html" title="Como::ComoCommon (class)">ComoCommon</a></span></span><span class='period'>.</span><span class='id identifier rubyid_setHook'><span class='object_link'><a href="Como/ComoCommon.html#setHook-class_method" title="Como::ComoCommon.setHook (method)">setHook</a></span></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> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="preHook-class_method"> .<strong>preHook</strong>(&code) ⇒ <tt>Object</tt> </h3><div class="docstring"> <div class="discussion"> <p>Set “preHook” routine.</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 563 564 565</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/como.rb', line 563</span> <span class='kw'>def</span> <span class='const'><span class='object_link'><a href="" title="Como (module)">Como</a></span></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> <span class='const'><span class='object_link'><a href="Como/ComoCommon.html" title="Como::ComoCommon (class)">ComoCommon</a></span></span><span class='period'>.</span><span class='id identifier rubyid_setHook'><span class='object_link'><a href="Como/ComoCommon.html#setHook-class_method" title="Como::ComoCommon.setHook (method)">setHook</a></span></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> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="version-class_method"> .<strong>version</strong> ⇒ <tt>Object</tt> </h3><table class="source_code"> <tr> <td> <pre class="lines"> 3 4 5</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/version.rb', line 3</span> <span class='kw'>def</span> <span class='const'><span class='object_link'><a href="" title="Como (module)">Como</a></span></span><span class='period'>.</span><span class='id identifier rubyid_version'>version</span> <span class='const'><span class='object_link'><a href="" title="Como (module)">Como</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="#VERSION-constant" title="Como::VERSION (constant)">VERSION</a></span></span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> </div> </div> <div id="footer"> Generated on Sun Oct 21 19:10:52 2018 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.16 (ruby-2.5.1). </div> </div> </body> </html>