ShogunPanda/bovem

View on GitHub
docs/Bovem/CommandMethods/Children.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
  Module: Bovem::CommandMethods::Children
  
    &mdash; Documentation by YARD 0.9.7
  
</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 = "Bovem::CommandMethods::Children";
  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> &raquo;
    <span class='title'><span class='object_link'><a href="../../Bovem.html" title="Bovem (module)">Bovem</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../CommandMethods.html" title="Bovem::CommandMethods (module)">CommandMethods</a></span></span>
     &raquo; 
    <span class="title">Children</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: Bovem::CommandMethods::Children
  
  
  
</h1>
<div class="box_info">
  

  
  
  
  
  

  
  <dl>
    <dt>Included in:</dt>
    <dd><span class='object_link'><a href="../Command.html" title="Bovem::Command (class)">Bovem::Command</a></span></dd>
  </dl>
  

  
  <dl>
    <dt>Defined in:</dt>
    <dd>lib/bovem/command.rb</dd>
  </dl>
  
</div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>Methods to manage options and subcommands.</p>


  </div>
</div>
<div class="tags">
  

</div>



  <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#commands-instance_method" title="#commands (instance method)">#<strong>commands</strong>  &#x21d2; HashWithIndifferentAccess </a>
    

    
  </span>
  
  
  
    
      <span class="note title readonly">readonly</span>
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Returns the list of subcommands of this command.</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#options-instance_method" title="#options (instance method)">#<strong>options</strong>  &#x21d2; HashWithIndifferentAccess </a>
    

    
  </span>
  
  
  
    
      <span class="note title readonly">readonly</span>
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Returns the list of options of this command.</p>
</div></span>
  
</li>

    
  </ul>




  
    <h2>
      Instance Method Summary
      <small><a href="#" class="summary_toggle">collapse</a></small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#argument-instance_method" title="#argument (instance method)">#<strong>argument</strong>(value)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Adds a new argument to this command.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#arguments-instance_method" title="#arguments (instance method)">#<strong>arguments</strong>  &#x21d2; Array </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Returns the list of arguments of this command.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#clear_commands-instance_method" title="#clear_commands (instance method)">#<strong>clear_commands</strong>  &#x21d2; Hash </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Clear all subcommands of this commands.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#clear_options-instance_method" title="#clear_options (instance method)">#<strong>clear_options</strong>  &#x21d2; Hash </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Clear all the options of this commands.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#command-instance_method" title="#command (instance method)">#<strong>command</strong>(name, options = {}, &amp;block)  &#x21d2; Command </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Adds a new subcommand to this command.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#commands%3F-instance_method" title="#commands? (instance method)">#<strong>commands?</strong>  &#x21d2; Boolean </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Check if this command has subcommands.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#get_options-instance_method" title="#get_options (instance method)">#<strong>get_options</strong>(unprovided: false, application: &quot;application_&quot;, prefix: &quot;&quot;, whitelist: [])  &#x21d2; HashWithIndifferentAccess </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <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 the user inputs or the defaults values.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#option-instance_method" title="#option (instance method)">#<strong>option</strong>(name, forms = [], options = {}, &amp;action)  &#x21d2; Option </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Adds a new option to this command.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#options%3F-instance_method" title="#options? (instance method)">#<strong>options?</strong>  &#x21d2; Boolean </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Check if this command has options.</p>
</div></span>
  
</li>

      
    </ul>
  


  <div id="instance_attr_details" class="attr_details">
    <h2>Instance Attribute Details</h2>
    
      
      <span id=""></span>
      <div class="method_details first">
  <h3 class="signature first" id="commands-instance_method">
  
    #<strong>commands</strong>  &#x21d2; <tt>HashWithIndifferentAccess</tt>  <span class="extras">(readonly)</span>
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns the list of subcommands of this command.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>HashWithIndifferentAccess</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The list of subcommands of this command.</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


176
177
178</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/command.rb', line 176</span>

<span class='kw'>def</span> <span class='id identifier rubyid_commands'>commands</span>
  <span class='ivar'>@commands</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id=""></span>
      <div class="method_details ">
  <h3 class="signature " id="options-instance_method">
  
    #<strong>options</strong>  &#x21d2; <tt>HashWithIndifferentAccess</tt>  <span class="extras">(readonly)</span>
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns the list of options of this command.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>HashWithIndifferentAccess</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The list of options of this command.</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


197
198
199</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/command.rb', line 197</span>

<span class='kw'>def</span> <span class='id identifier rubyid_options'>options</span>
  <span class='ivar'>@options</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="argument-instance_method">
  
    #<strong>argument</strong>(value)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Adds a new argument to this command.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>value</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The argument to add.</p>
</div>
      
    </li>
  
</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


217
218
219
220</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/command.rb', line 217</span>

<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>
  <span class='ivar'>@args</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
  <span class='ivar'>@args</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_value'>value</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="arguments-instance_method">
  
    #<strong>arguments</strong>  &#x21d2; <tt>Array</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns the list of arguments of this command.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The list of arguments of this command.</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


225
226
227</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/command.rb', line 225</span>

<span class='kw'>def</span> <span class='id identifier rubyid_arguments'>arguments</span>
  <span class='ivar'>@args</span> <span class='op'>||</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="clear_commands-instance_method">
  
    #<strong>clear_commands</strong>  &#x21d2; <tt>Hash</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Clear all subcommands of this commands.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The new (empty) list of subcommands of this command.</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


183
184
185</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/command.rb', line 183</span>

<span class='kw'>def</span> <span class='id identifier rubyid_clear_commands'>clear_commands</span>
  <span class='ivar'>@commands</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="clear_options-instance_method">
  
    #<strong>clear_options</strong>  &#x21d2; <tt>Hash</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Clear all the options of this commands.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The new (empty) list of the options of this command.</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


203
204
205</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/command.rb', line 203</span>

<span class='kw'>def</span> <span class='id identifier rubyid_clear_options'>clear_options</span>
  <span class='ivar'>@options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="command-instance_method">
  
    #<strong>command</strong>(name, options = {}, &amp;block)  &#x21d2; <tt><span class='object_link'><a href="../Command.html" title="Bovem::Command (class)">Command</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Adds a new subcommand to this command.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>name</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The name of this command. Must be unique.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>options</span>
      
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>{}</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>A set of options for this command.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../Command.html" title="Bovem::Command (class)">Command</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The newly added command.</p>
</div>
      
    </li>
  
</ul>
<p class="tag_title">Raises:</p>
<ul class="raise">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../Errors/Error.html" title="Bovem::Errors::Error (class)">Bovem::Errors::Error</a></span></tt>)</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


141
142
143
144
145
146
147
148</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/command.rb', line 141</span>

<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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
  <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>

  <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>
  <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></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>

  <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="commands?-instance_method">
  
    #<strong>commands?</strong>  &#x21d2; <tt>Boolean</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Check if this command has subcommands.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p><code>true</code> if this command has subcommands, <code>false</code> otherwise.</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


190
191
192</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/command.rb', line 190</span>

<span class='kw'>def</span> <span class='id identifier rubyid_commands?'>commands?</span>
  <span class='op'>!</span><span class='id identifier rubyid_commands'>commands</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="get_options-instance_method">
  
    #<strong>get_options</strong>(unprovided: false, application: &quot;application_&quot;, prefix: &quot;&quot;, whitelist: [])  &#x21d2; <tt>HashWithIndifferentAccess</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Get the list of the options of this command as an hash, where the keys are the options and the values are either
the user inputs or the defaults values.</p>

<p>If the two prefixes collides, the command options take precedence over application options.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>unprovided</span>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <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>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>application</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The prefix to use for including application’s options. If falsy, only current command options will be included.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>prefix</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The prefix to add to the option of this command.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>whitelist</span>
      
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The list of options to include. By default all options are included.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>HashWithIndifferentAccess</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The requested options.</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


239
240
241
242
243
244
245
246
247
248</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/command.rb', line 239</span>

<span class='kw'>def</span> <span class='id identifier rubyid_get_options'>get_options</span><span class='lparen'>(</span><span class='label'>unprovided:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>application:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>application_</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>prefix:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>whitelist:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
  <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>

  <span class='kw'>if</span> <span class='id identifier rubyid_application'>application</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_application?'>application?</span>
    <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='label'>unprovided:</span> <span class='id identifier rubyid_unprovided'>unprovided</span><span class='comma'>,</span> <span class='label'>application:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>prefix:</span> <span class='id identifier rubyid_application'>application</span><span class='comma'>,</span> <span class='label'>whitelist:</span> <span class='id identifier rubyid_whitelist'>whitelist</span><span class='rparen'>)</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <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>
  <span class='id identifier rubyid_rv'>rv</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="option-instance_method">
  
    #<strong>option</strong>(name, forms = [], options = {}, &amp;action)  &#x21d2; <tt><span class='object_link'><a href="../Option.html" title="Bovem::Option (class)">Option</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Adds a new option to this command.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>name</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The name of the option. Must be unique.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>forms</span>
      
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>[]</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>An array of short and long forms for this option.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>options</span>
      
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>{}</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>The settings for the option.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>action</span>
      
      
        <span class='type'>(<tt>Proc</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>An optional action to pass to the option.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../Option.html" title="Bovem::Option (class)">Option</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The newly added option.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Option.html#initialize-instance_method" title="Bovem::Option#initialize (method)">Option#initialize</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


159
160
161
162
163
164
165
166
167
168
169
170
171</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/command.rb', line 159</span>

<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'>&amp;</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
  <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>
  <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>

  <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='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></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_application?'>application?</span> <span class='op'>?</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='op'>:</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>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_option'>option</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Option.html" title="Bovem::Option (class)">Option</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../Option.html#initialize-instance_method" title="Bovem::Option#initialize (method)">new</a></span></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'>&amp;</span><span class='id identifier rubyid_action'>action</span><span class='rparen'>)</span>
  <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>
  <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>
  <span class='id identifier rubyid_option'>option</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="options?-instance_method">
  
    #<strong>options?</strong>  &#x21d2; <tt>Boolean</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Check if this command has options.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p><code>true</code> if this command has options, <code>false</code> otherwise.</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


210
211
212</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/command.rb', line 210</span>

<span class='kw'>def</span> <span class='id identifier rubyid_options?'>options?</span>
  <span class='op'>!</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>

      <div id="footer">
  Generated on Thu Jan 12 16:10:58 2017 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.9.7 (ruby-2.3.0).
</div>

    </div>
  </body>
</html>