CINXE.COM

Module: Thor::Base::ClassMethods — Documentation for thor (1.3.2)

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title> Module: Thor::Base::ClassMethods &mdash; Documentation for thor (1.3.2) </title> <link rel="stylesheet" href="/static/gems/thor/css/style.css?1732340652" type="text/css" /> <link rel="stylesheet" href="/static/gems/thor/css/common.css?1732340652" type="text/css" /> <link rel="stylesheet" href="/static/gems/thor/css/custom.css?1732340652" type="text/css" /> <script type="text/javascript" charset="utf-8"> pathId = "Thor::Base::ClassMethods" relpath = '/'; docsPrefix = '/gems/thor'; listPrefix = '/list/gems/thor'; searchPrefix = '/search/gems/thor'; </script> <script type="text/javascript" charset="utf-8" src="/static/gems/thor/js/jquery.js?1732340652"></script> <script type="text/javascript" charset="utf-8" src="/static/gems/thor/js/app.js?1732340652"></script> <script type="text/javascript" charset="utf-8" src="/static/gems/thor/js/autocomplete.js?1732340652"></script> <script type="text/javascript" charset="utf-8" src="/static/gems/thor/js/rubydoc_custom.js?1732340652"></script> </head> <body> <div class="nav_wrap"> <iframe id="nav" src="/list/gems/thor/class?1"></iframe> <div id="resizer"></div> </div> <div id="main" tabindex="-1"> <div id="header"> <form class="search" method="get" action="/search/gems/thor"> <input name="q" type="search" placeholder="Search" id="search_box" size="30" value="" /> </form> <script type="text/javascript" charset="utf-8"> $(function() { $('#search_box').autocomplete($('#search_box').parent().attr('action'), { width: 200, formatItem: function(item) { var values = item[0].split(","); return values[0] + (values[1] == '' ? "" : " <small>(" + values[1] + ")</small>"); } }).result(function(event, item) { var values = item[0].split(",") $('#search_box').val(values[1]); location.href = values[3]; return false; }); }); </script> <div id="menu"> <a href="/gems" target="_top">Libraries</a> &raquo; <span class="title">thor <small>(1.3.2)</small></span> &raquo; <a href="/gems/thor/index">Index (C)</a> &raquo; <span class='title'><span class='object_link'><a href="/gems/thor/Thor" title="Thor (class)">Thor</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="/gems/thor/Thor/Base" title="Thor::Base (module)">Base</a></span></span> &raquo; <span class='title'>ClassMethods</span> </div> <div id="search"> <a class="full_list_link" id="class_list_link" href="/list/gems/thor/class"> <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: Thor::Base::ClassMethods </h1> <div class="box_info"> <dl> <dt>Defined in:</dt> <dd>lib/thor/base.rb</dd> </dl> </div> <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="/gems/thor/Thor/Base/ClassMethods#all_commands-instance_method" title="#all_commands (instance method)">#<strong>all_commands</strong> &#x21d2; Object </a> (also: #all_tasks) </span> <span class="summary_desc"><div class='inline'> <p>Returns the commands for this Thor class and all subclasses.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#allow_incompatible_default_type!-instance_method" title="#allow_incompatible_default_type! (instance method)">#<strong>allow_incompatible_default_type!</strong> &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>If you want to use defaults that don’t match the type of an option, either specify ‘check_default_type: false` or call `allow_incompatible_default_type!`.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#argument-instance_method" title="#argument (instance method)">#<strong>argument</strong>(name, options = {}) &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>Adds an argument to the class and creates an attr_accessor for it.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#arguments-instance_method" title="#arguments (instance method)">#<strong>arguments</strong> &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>Returns this class arguments, looking up in the ancestors chain.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#attr_accessor-instance_method" title="#attr_accessor (instance method)">#<strong>attr_accessor</strong> &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>:nodoc:.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#attr_reader-instance_method" title="#attr_reader (instance method)">#<strong>attr_reader</strong> &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>:nodoc:.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#attr_writer-instance_method" title="#attr_writer (instance method)">#<strong>attr_writer</strong> &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>:nodoc:.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#check_default_type-instance_method" title="#check_default_type (instance method)">#<strong>check_default_type</strong> &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>:nodoc:.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#check_default_type!-instance_method" title="#check_default_type! (instance method)">#<strong>check_default_type!</strong> &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>If you want to raise an error when the default value of an option does not match the type call check_default_type! This will be the default; for compatibility a deprecation warning is issued if necessary.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#check_unknown_options-instance_method" title="#check_unknown_options (instance method)">#<strong>check_unknown_options</strong> &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>:nodoc:.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#check_unknown_options!-instance_method" title="#check_unknown_options! (instance method)">#<strong>check_unknown_options!</strong> &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>If you want to raise an error for unknown options, call check_unknown_options! This is disabled by default to allow dynamic invocations.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#check_unknown_options%3F-instance_method" title="#check_unknown_options? (instance method)">#<strong>check_unknown_options?</strong>(config) &#x21d2; Boolean </a> </span> <span class="summary_desc"><div class='inline'> <p>:nodoc:.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#class_at_least_one-instance_method" title="#class_at_least_one (instance method)">#<strong>class_at_least_one</strong>(*args, &amp;block) &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>Adds and declares option group for required at least one of options in the block and arguments.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#class_at_least_one_option_names-instance_method" title="#class_at_least_one_option_names (instance method)">#<strong>class_at_least_one_option_names</strong> &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>Returns this class at least one of required options array set, looking up in the ancestors chain.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#class_exclusive-instance_method" title="#class_exclusive (instance method)">#<strong>class_exclusive</strong>(*args, &amp;block) &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>Adds and declares option group for exclusive options in the block and arguments.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#class_exclusive_option_names-instance_method" title="#class_exclusive_option_names (instance method)">#<strong>class_exclusive_option_names</strong> &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>Returns this class exclusive options array set, looking up in the ancestors chain.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#class_option-instance_method" title="#class_option (instance method)">#<strong>class_option</strong>(name, options = {}) &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>Adds an option to the set of class options.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#class_options-instance_method" title="#class_options (instance method)">#<strong>class_options</strong>(options = nil) &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>Adds a bunch of options to the set of class options.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#commands-instance_method" title="#commands (instance method)">#<strong>commands</strong> &#x21d2; Object </a> (also: #tasks) </span> <span class="summary_desc"><div class='inline'> <p>Returns the commands for this Thor class.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#disable_required_check%3F-instance_method" title="#disable_required_check? (instance method)">#<strong>disable_required_check?</strong>(command_name) &#x21d2; Boolean </a> </span> <span class="summary_desc"><div class='inline'> <p>If true, option set will not suspend the execution of the command when a required option is not provided.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#exit_on_failure%3F-instance_method" title="#exit_on_failure? (instance method)">#<strong>exit_on_failure?</strong> &#x21d2; Boolean </a> </span> <span class="summary_desc"><div class='inline'> <p>A flag that makes the process exit with status 1 if any error happens.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#group-instance_method" title="#group (instance method)">#<strong>group</strong>(name = nil) &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>Defines the group.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#handle_argument_error-instance_method" title="#handle_argument_error (instance method)">#<strong>handle_argument_error</strong>(command, error, args, arity) &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>:nodoc:.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#handle_no_command_error-instance_method" title="#handle_no_command_error (instance method)">#<strong>handle_no_command_error</strong>(command, has_namespace = $thor_runner) &#x21d2; Object </a> (also: #handle_no_task_error) </span> <span class="summary_desc"><div class='inline'> <p>:nodoc:.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#namespace-instance_method" title="#namespace (instance method)">#<strong>namespace</strong>(name = nil) &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>Sets the namespace for the Thor or Thor::Group class.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#no_commands-instance_method" title="#no_commands (instance method)">#<strong>no_commands</strong>(&amp;block) &#x21d2; Object </a> (also: #no_tasks) </span> <span class="summary_desc"><div class='inline'> <p>All methods defined inside the given block are not added as commands.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#no_commands%3F-instance_method" title="#no_commands? (instance method)">#<strong>no_commands?</strong> &#x21d2; Boolean </a> </span> <span class="summary_desc"><div class='inline'></div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#no_commands_context-instance_method" title="#no_commands_context (instance method)">#<strong>no_commands_context</strong> &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'></div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#public_command-instance_method" title="#public_command (instance method)">#<strong>public_command</strong>(*names) &#x21d2; Object </a> (also: #public_task) </span> <span class="summary_desc"><div class='inline'> <p>Allows to use private methods from parent in child classes as commands.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#remove_argument-instance_method" title="#remove_argument (instance method)">#<strong>remove_argument</strong>(*names) &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>Removes a previous defined argument.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#remove_class_option-instance_method" title="#remove_class_option (instance method)">#<strong>remove_class_option</strong>(*names) &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>Removes a previous defined class option.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#remove_command-instance_method" title="#remove_command (instance method)">#<strong>remove_command</strong>(*names) &#x21d2; Object </a> (also: #remove_task) </span> <span class="summary_desc"><div class='inline'> <p>Removes a given command from this Thor class.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#start-instance_method" title="#start (instance method)">#<strong>start</strong>(given_args = ARGV, config = {}) &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>Parses the command and options from the given args, instantiate the class and invoke the command.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#stop_on_unknown_option%3F-instance_method" title="#stop_on_unknown_option? (instance method)">#<strong>stop_on_unknown_option?</strong>(command_name) &#x21d2; Boolean </a> </span> <span class="summary_desc"><div class='inline'> <p>If true, option parsing is suspended as soon as an unknown option or a regular argument is encountered.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#strict_args_position-instance_method" title="#strict_args_position (instance method)">#<strong>strict_args_position</strong> &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>:nodoc:.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#strict_args_position!-instance_method" title="#strict_args_position! (instance method)">#<strong>strict_args_position!</strong> &#x21d2; Object </a> </span> <span class="summary_desc"><div class='inline'> <p>If you want only strict string args (useful when cascading thor classes), call strict_args_position! This is disabled by default to allow dynamic invocations.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> <a href="/gems/thor/Thor/Base/ClassMethods#strict_args_position%3F-instance_method" title="#strict_args_position? (instance method)">#<strong>strict_args_position?</strong>(config) &#x21d2; Boolean </a> </span> <span class="summary_desc"><div class='inline'> <p>:nodoc:.</p> </div></span> </li> </ul> <div id="instance_method_details" class="method_details_list"> <h2>Instance Method Details</h2> <div class="method_details first"> <h3 class="signature first" id="all_commands-instance_method"> #<strong>all_commands</strong> &#x21d2; <tt>Object</tt> <span class="aliases">Also known as: <span class="names"><span id='all_tasks-instance_method'>all_tasks</span></span> </span> </h3><script> $(document.getElementById("all_commands-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:all_commands">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>Returns the commands for this Thor class and all subclasses.</p> <h4 id="label-Returns">Returns</h4> <dl class="rdoc-list note-list"><dt>Hash <dd> <p>An ordered hash with commands names as keys and Thor::Command objects as values.</p> </dd></dl> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 482 483 484 485</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 482</span> <span class='kw'>def</span> <span class='id identifier rubyid_all_commands'>all_commands</span> <span class='ivar'>@all_commands</span> <span class='op'>||=</span> <span class='id identifier rubyid_from_superclass'>from_superclass</span><span class='lparen'>(</span><span class='symbol'>:all_commands</span><span class='comma'>,</span> <span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span> <span class='ivar'>@all_commands</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span><span class='lparen'>(</span><span class='id identifier rubyid_commands'>commands</span><span class='rparen'>)</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="allow_incompatible_default_type!-instance_method"> #<strong>allow_incompatible_default_type!</strong> &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("allow_incompatible_default_type!-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:allow_incompatible_default_type!">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>If you want to use defaults that don’t match the type of an option, either specify ‘check_default_type: false` or call `allow_incompatible_default_type!`</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 189 190 191</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 189</span> <span class='kw'>def</span> <span class='id identifier rubyid_allow_incompatible_default_type!'>allow_incompatible_default_type!</span> <span class='ivar'>@check_default_type</span> <span class='op'>=</span> <span class='kw'>false</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="argument-instance_method"> #<strong>argument</strong>(name, options = {}) &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("argument-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:argument">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>Adds an argument to the class and creates an attr_accessor for it.</p> <p>Arguments are different from options in several aspects. The first one is how they are parsed from the command line, arguments are retrieved from position:</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_thor'>thor</span> <span class='id identifier rubyid_command'>command</span> <span class='const'>NAME</span> </code></pre> <p>Instead of:</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_thor'>thor</span> <span class='id identifier rubyid_command'>command</span> <span class='op'>-</span><span class='op'>-</span><span class='id identifier rubyid_name'>name</span><span class='op'>=</span><span class='const'>NAME</span> </code></pre> <p>Besides, arguments are used inside your code as an accessor (self.argument), while options are all kept in a hash (self.options).</p> <p>Finally, arguments cannot have type :default or :boolean but can be optional (supplying :optional =&gt; :true or :required =&gt; false), although you cannot have a required argument after a non-required argument. If you try it, an error is raised.</p> <h4 id="label-Parameters">Parameters</h4> <dl class="rdoc-list note-list"><dt>name&lt;Symbol&gt; <dd> <p>The name of the argument.</p> </dd><dt>options&lt;Hash&gt; <dd> <p>Described below.</p> </dd></dl> <h4 id="label-Options">Options</h4> <p>:desc - Description for the argument. :required - If the argument is required or not. :optional - If the argument is optional or not. :type - The type of the argument, can be :string, :hash, :array, :numeric. :default - Default value for this argument. It cannot be required and have default values. :banner - String to show on usage notes.</p> <h4 id="label-Errors">Errors</h4> <dl class="rdoc-list note-list"><dt>ArgumentError <dd> <p>Raised if you supply a required argument after a non required one.</p> </dd></dl> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 261</span> <span class='kw'>def</span> <span class='id identifier rubyid_argument'>argument</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='rparen'>)</span> <span class='id identifier rubyid_is_thor_reserved_word?'>is_thor_reserved_word?</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='symbol'>:argument</span><span class='rparen'>)</span> <span class='id identifier rubyid_no_commands'>no_commands</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='id identifier rubyid_name'>name</span> <span class='rbrace'>}</span> <span class='id identifier rubyid_required'>required</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span><span class='lparen'>(</span><span class='symbol'>:optional</span><span class='rparen'>)</span> <span class='op'>!</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:optional</span><span class='rbracket'>]</span> <span class='kw'>elsif</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span><span class='lparen'>(</span><span class='symbol'>:required</span><span class='rparen'>)</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:required</span><span class='rbracket'>]</span> <span class='kw'>else</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:default</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='kw'>end</span> <span class='id identifier rubyid_remove_argument'>remove_argument</span> <span class='id identifier rubyid_name'>name</span> <span class='kw'>if</span> <span class='id identifier rubyid_required'>required</span> <span class='id identifier rubyid_arguments'>arguments</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_argument'>argument</span><span class='op'>|</span> <span class='kw'>next</span> <span class='kw'>if</span> <span class='id identifier rubyid_argument'>argument</span><span class='period'>.</span><span class='id identifier rubyid_required?'>required?</span> <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>You cannot have </span><span class='embexpr_beg'>#{</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='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'> as required argument after </span><span class='tstring_end'>&quot;</span></span> \ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>the non-required argument </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_argument'>argument</span><span class='period'>.</span><span class='id identifier rubyid_human_name'>human_name</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'>.</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>end</span> <span class='kw'>end</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:required</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_required'>required</span> <span class='id identifier rubyid_arguments'>arguments</span> <span class='op'>&lt;&lt;</span> <span class='const'><span class='object_link'><a href="/gems/thor/Thor" title="Thor (class)">Thor</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="/gems/thor/Thor/Argument" title="Thor::Argument (class)">Argument</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="/gems/thor/Thor/Argument#initialize-instance_method" title="Thor::Argument#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_options'>options</span><span class='rparen'>)</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>Object</tt> </h3><script> $(document.getElementById("arguments-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:arguments">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>Returns this class arguments, looking up in the ancestors chain.</p> <h4 id="label-Returns">Returns</h4> <p><a href="Thor::Argument">Array</a></p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 293 294 295</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 293</span> <span class='kw'>def</span> <span class='id identifier rubyid_arguments'>arguments</span> <span class='ivar'>@arguments</span> <span class='op'>||=</span> <span class='id identifier rubyid_from_superclass'>from_superclass</span><span class='lparen'>(</span><span class='symbol'>:arguments</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="attr_accessor-instance_method"> #<strong>attr_accessor</strong> &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("attr_accessor-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:attr_accessor">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>:nodoc:</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 162 163 164</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 162</span> <span class='kw'>def</span> <span class='id identifier rubyid_attr_accessor'>attr_accessor</span><span class='lparen'>(</span><span class='op'>*</span><span class='rparen'>)</span> <span class='comment'>#:nodoc: </span> <span class='id identifier rubyid_no_commands'>no_commands</span> <span class='lbrace'>{</span> <span class='kw'>super</span> <span class='rbrace'>}</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="attr_reader-instance_method"> #<strong>attr_reader</strong> &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("attr_reader-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:attr_reader">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>:nodoc:</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 154 155 156</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 154</span> <span class='kw'>def</span> <span class='id identifier rubyid_attr_reader'>attr_reader</span><span class='lparen'>(</span><span class='op'>*</span><span class='rparen'>)</span> <span class='comment'>#:nodoc: </span> <span class='id identifier rubyid_no_commands'>no_commands</span> <span class='lbrace'>{</span> <span class='kw'>super</span> <span class='rbrace'>}</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="attr_writer-instance_method"> #<strong>attr_writer</strong> &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("attr_writer-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:attr_writer">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>:nodoc:</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 158 159 160</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 158</span> <span class='kw'>def</span> <span class='id identifier rubyid_attr_writer'>attr_writer</span><span class='lparen'>(</span><span class='op'>*</span><span class='rparen'>)</span> <span class='comment'>#:nodoc: </span> <span class='id identifier rubyid_no_commands'>no_commands</span> <span class='lbrace'>{</span> <span class='kw'>super</span> <span class='rbrace'>}</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="check_default_type-instance_method"> #<strong>check_default_type</strong> &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("check_default_type-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:check_default_type">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>:nodoc:</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 193 194 195 196</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 193</span> <span class='kw'>def</span> <span class='id identifier rubyid_check_default_type'>check_default_type</span> <span class='comment'>#:nodoc: </span> <span class='ivar'>@check_default_type</span> <span class='op'>=</span> <span class='id identifier rubyid_from_superclass'>from_superclass</span><span class='lparen'>(</span><span class='symbol'>:check_default_type</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='kw'>defined?</span><span class='lparen'>(</span><span class='ivar'>@check_default_type</span><span class='rparen'>)</span> <span class='ivar'>@check_default_type</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="check_default_type!-instance_method"> #<strong>check_default_type!</strong> &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("check_default_type!-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:check_default_type!">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>If you want to raise an error when the default value of an option does not match the type call check_default_type! This will be the default; for compatibility a deprecation warning is issued if necessary.</p> </div> </div> <div class="tags"> </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/thor/base.rb', line 183</span> <span class='kw'>def</span> <span class='id identifier rubyid_check_default_type!'>check_default_type!</span> <span class='ivar'>@check_default_type</span> <span class='op'>=</span> <span class='kw'>true</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="check_unknown_options-instance_method"> #<strong>check_unknown_options</strong> &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("check_unknown_options-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:check_unknown_options">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>:nodoc:</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 172 173 174</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 172</span> <span class='kw'>def</span> <span class='id identifier rubyid_check_unknown_options'>check_unknown_options</span> <span class='comment'>#:nodoc: </span> <span class='ivar'>@check_unknown_options</span> <span class='op'>||=</span> <span class='id identifier rubyid_from_superclass'>from_superclass</span><span class='lparen'>(</span><span class='symbol'>:check_unknown_options</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="check_unknown_options!-instance_method"> #<strong>check_unknown_options!</strong> &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("check_unknown_options!-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:check_unknown_options!">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>If you want to raise an error for unknown options, call check_unknown_options! This is disabled by default to allow dynamic invocations.</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 168 169 170</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 168</span> <span class='kw'>def</span> <span class='id identifier rubyid_check_unknown_options!'>check_unknown_options!</span> <span class='ivar'>@check_unknown_options</span> <span class='op'>=</span> <span class='kw'>true</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="check_unknown_options?-instance_method"> #<strong>check_unknown_options?</strong>(config) &#x21d2; <tt>Boolean</tt> </h3><script> $(document.getElementById("check_unknown_options?-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:check_unknown_options%3F">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>:nodoc:</p> </div> </div> <div class="tags"> <p class="tag_title">Returns:</p> <ul class="return"> <li> <span class='type'>(<tt>Boolean</tt>)</span> </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/thor/base.rb', line 176</span> <span class='kw'>def</span> <span class='id identifier rubyid_check_unknown_options?'>check_unknown_options?</span><span class='lparen'>(</span><span class='id identifier rubyid_config'>config</span><span class='rparen'>)</span> <span class='comment'>#:nodoc: </span> <span class='op'>!</span><span class='op'>!</span><span class='id identifier rubyid_check_unknown_options'>check_unknown_options</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="class_at_least_one-instance_method"> #<strong>class_at_least_one</strong>(*args, &amp;block) &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("class_at_least_one-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:class_at_least_one">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>Adds and declares option group for required at least one of options in the block and arguments. You can declare options as the outside of the block.</p> <h4 id="label-Examples">Examples</h4> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_class_at_least_one'>class_at_least_one</span> <span class='kw'>do</span> <span class='id identifier rubyid_class_option'>class_option</span> <span class='symbol'>:one</span> <span class='id identifier rubyid_class_option'>class_option</span> <span class='symbol'>:two</span> <span class='kw'>end</span> </code></pre> <p>Or</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_class_option'>class_option</span> <span class='symbol'>:one</span> <span class='id identifier rubyid_class_option'>class_option</span> <span class='symbol'>:two</span> <span class='id identifier rubyid_class_at_least_one'>class_at_least_one</span> <span class='symbol'>:one</span><span class='comma'>,</span> <span class='symbol'>:two</span> </code></pre> <p>If you do not give “–one” and “–two” AtLeastOneRequiredArgumentError will be raised.</p> <p>You can use class_at_least_one and class_exclusive at the same time.</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_class_exclusive'>class_exclusive</span> <span class='kw'>do</span> <span class='id identifier rubyid_class_at_least_one'>class_at_least_one</span> <span class='kw'>do</span> <span class='id identifier rubyid_class_option'>class_option</span> <span class='symbol'>:one</span> <span class='id identifier rubyid_class_option'>class_option</span> <span class='symbol'>:two</span> <span class='kw'>end</span> <span class='kw'>end</span> </code></pre> <p>Then it is required either only one of “–one” or “–two”.</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 392 393 394 395</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 392</span> <span class='kw'>def</span> <span class='id identifier rubyid_class_at_least_one'>class_at_least_one</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> <span class='id identifier rubyid_register_options_relation_for'>register_options_relation_for</span><span class='lparen'>(</span><span class='symbol'>:class_options</span><span class='comma'>,</span> <span class='symbol'>:class_at_least_one_option_names</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</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="class_at_least_one_option_names-instance_method"> #<strong>class_at_least_one_option_names</strong> &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("class_at_least_one_option_names-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:class_at_least_one_option_names">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>Returns this class at least one of required options array set, looking up in the ancestors chain.</p> <h4 id="label-Returns">Returns</h4> <p><a href="Thor::Option.name">Array[Array</a>]</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 411 412 413</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 411</span> <span class='kw'>def</span> <span class='id identifier rubyid_class_at_least_one_option_names'>class_at_least_one_option_names</span> <span class='ivar'>@class_at_least_one_option_names</span> <span class='op'>||=</span> <span class='id identifier rubyid_from_superclass'>from_superclass</span><span class='lparen'>(</span><span class='symbol'>:class_at_least_one_option_names</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="class_exclusive-instance_method"> #<strong>class_exclusive</strong>(*args, &amp;block) &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("class_exclusive-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:class_exclusive">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>Adds and declares option group for exclusive options in the block and arguments. You can declare options as the outside of the block.</p> <h4 id="label-Parameters">Parameters</h4> <p><a href="Thor::Option.name">Array</a></p> <h4 id="label-Examples">Examples</h4> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_class_exclusive'>class_exclusive</span> <span class='kw'>do</span> <span class='id identifier rubyid_class_option'>class_option</span> <span class='symbol'>:one</span> <span class='id identifier rubyid_class_option'>class_option</span> <span class='symbol'>:two</span> <span class='kw'>end</span> </code></pre> <p>Or</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_class_option'>class_option</span> <span class='symbol'>:one</span> <span class='id identifier rubyid_class_option'>class_option</span> <span class='symbol'>:two</span> <span class='id identifier rubyid_class_exclusive'>class_exclusive</span> <span class='symbol'>:one</span><span class='comma'>,</span> <span class='symbol'>:two</span> </code></pre> <p>If you give “–one” and “–two” at the same time ExclusiveArgumentsError will be raised.</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 357 358 359 360</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 357</span> <span class='kw'>def</span> <span class='id identifier rubyid_class_exclusive'>class_exclusive</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> <span class='id identifier rubyid_register_options_relation_for'>register_options_relation_for</span><span class='lparen'>(</span><span class='symbol'>:class_options</span><span class='comma'>,</span> <span class='symbol'>:class_exclusive_option_names</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</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="class_exclusive_option_names-instance_method"> #<strong>class_exclusive_option_names</strong> &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("class_exclusive_option_names-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:class_exclusive_option_names">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>Returns this class exclusive options array set, looking up in the ancestors chain.</p> <h4 id="label-Returns">Returns</h4> <p><a href="Thor::Option.name">Array[Array</a>]</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 402 403 404</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 402</span> <span class='kw'>def</span> <span class='id identifier rubyid_class_exclusive_option_names'>class_exclusive_option_names</span> <span class='ivar'>@class_exclusive_option_names</span> <span class='op'>||=</span> <span class='id identifier rubyid_from_superclass'>from_superclass</span><span class='lparen'>(</span><span class='symbol'>:class_exclusive_option_names</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="class_option-instance_method"> #<strong>class_option</strong>(name, options = {}) &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("class_option-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:class_option">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>Adds an option to the set of class options</p> <h4 id="label-Parameters">Parameters</h4> <dl class="rdoc-list note-list"><dt>name&lt;Symbol&gt; <dd> <p>The name of the argument.</p> </dd><dt>options&lt;Hash&gt; <dd> <p>Described below.</p> </dd></dl> <h4 id="label-Options">Options</h4> <dl class="rdoc-list note-list"><dt>:desc <dd> <p>– Description for the argument.</p> </dd><dt>:required <dd> <p>– If the argument is required or not.</p> </dd><dt>:default <dd> <p>– Default value for this argument.</p> </dd><dt>:group <dd> <p>– The group for this options. Use by class options to output options in different levels.</p> </dd><dt>:aliases <dd> <p>– Aliases for this option. <strong>Note:</strong> Thor follows a convention of one-dash-one-letter options. Thus aliases like “-something” wouldn’t be parsed; use either “--something” or “-s” instead.</p> </dd><dt>:type <dd> <p>– The type of the argument, can be :string, :hash, :array, :numeric or :boolean.</p> </dd><dt>:banner <dd> <p>– String to show on usage notes.</p> </dd><dt>:hide <dd> <p>– If you want to hide this option from the help.</p> </dd></dl> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 328 329 330 331 332 333</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 328</span> <span class='kw'>def</span> <span class='id identifier rubyid_class_option'>class_option</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='rparen'>)</span> <span class='kw'>unless</span> <span class='lbracket'>[</span> <span class='const'>Symbol</span><span class='comma'>,</span> <span class='const'>String</span> <span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_klass'>klass</span><span class='op'>|</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='rparen'>)</span> <span class='rbrace'>}</span> <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Expected a Symbol or String, got </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>end</span> <span class='id identifier rubyid_build_option'>build_option</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='id identifier rubyid_class_options'>class_options</span><span class='rparen'>)</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="class_options-instance_method"> #<strong>class_options</strong>(options = nil) &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("class_options-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:class_options">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>Adds a bunch of options to the set of class options.</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_class_options'>class_options</span> <span class='symbol'>:foo</span> <span class='op'>=&gt;</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='symbol'>:bar</span> <span class='op'>=&gt;</span> <span class='symbol'>:required</span><span class='comma'>,</span> <span class='symbol'>:baz</span> <span class='op'>=&gt;</span> <span class='symbol'>:string</span> </code></pre> <p>If you prefer more detailed declaration, check class_option.</p> <h4 id="label-Parameters">Parameters</h4> <p>Hash[Symbol =&gt; Object]</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 306 307 308 309 310</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 306</span> <span class='kw'>def</span> <span class='id identifier rubyid_class_options'>class_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span> <span class='ivar'>@class_options</span> <span class='op'>||=</span> <span class='id identifier rubyid_from_superclass'>from_superclass</span><span class='lparen'>(</span><span class='symbol'>:class_options</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='id identifier rubyid_build_options'>build_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='ivar'>@class_options</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_options'>options</span> <span class='ivar'>@class_options</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>Object</tt> <span class="aliases">Also known as: <span class="names"><span id='tasks-instance_method'>tasks</span></span> </span> </h3><script> $(document.getElementById("commands-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:commands">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>Returns the commands for this Thor class.</p> <h4 id="label-Returns">Returns</h4> <dl class="rdoc-list note-list"><dt>Hash <dd> <p>An ordered hash with commands names as keys and Thor::Command objects as values.</p> </dd></dl> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 471 472 473</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 471</span> <span class='kw'>def</span> <span class='id identifier rubyid_commands'>commands</span> <span class='ivar'>@commands</span> <span class='op'>||=</span> <span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="disable_required_check?-instance_method"> #<strong>disable_required_check?</strong>(command_name) &#x21d2; <tt>Boolean</tt> </h3><script> $(document.getElementById("disable_required_check?-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:disable_required_check%3F">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>If true, option set will not suspend the execution of the command when a required option is not provided.</p> </div> </div> <div class="tags"> <p class="tag_title">Returns:</p> <ul class="return"> <li> <span class='type'>(<tt>Boolean</tt>)</span> </li> </ul> </div><table class="source_code"> <tr> <td> <pre class="lines"> 207 208 209</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 207</span> <span class='kw'>def</span> <span class='id identifier rubyid_disable_required_check?'>disable_required_check?</span><span class='lparen'>(</span><span class='id identifier rubyid_command_name'>command_name</span><span class='rparen'>)</span> <span class='comment'>#:nodoc: </span> <span class='kw'>false</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="exit_on_failure?-instance_method"> #<strong>exit_on_failure?</strong> &#x21d2; <tt>Boolean</tt> </h3><script> $(document.getElementById("exit_on_failure?-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:exit_on_failure%3F">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>A flag that makes the process exit with status 1 if any error happens.</p> </div> </div> <div class="tags"> <p class="tag_title">Returns:</p> <ul class="return"> <li> <span class='type'>(<tt>Boolean</tt>)</span> </li> </ul> </div><table class="source_code"> <tr> <td> <pre class="lines"> 628 629 630 631</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 628</span> <span class='kw'>def</span> <span class='id identifier rubyid_exit_on_failure?'>exit_on_failure?</span> <span class='const'><span class='object_link'><a href="/gems/thor/Thor" title="Thor (class)">Thor</a></span></span><span class='period'>.</span><span class='id identifier rubyid_deprecation_warning'><span class='object_link'><a href="/gems/thor/Thor#deprecation_warning-class_method" title="Thor.deprecation_warning (method)">deprecation_warning</a></span></span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Thor exit with status 0 on errors. To keep this behavior, you must define `exit_on_failure?` in `</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'>`</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>false</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="group-instance_method"> #<strong>group</strong>(name = nil) &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("group-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:group">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>Defines the group. This is used when thor list is invoked so you can specify that only commands from a pre-defined group will be shown. Defaults to standard.</p> <h4 id="label-Parameters">Parameters</h4> <p>name&lt;String|Symbol&gt;</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 457 458 459 460 461 462 463</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 457</span> <span class='kw'>def</span> <span class='id identifier rubyid_group'>group</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_name'>name</span> <span class='ivar'>@group</span> <span class='op'>=</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='kw'>else</span> <span class='ivar'>@group</span> <span class='op'>||=</span> <span class='id identifier rubyid_from_superclass'>from_superclass</span><span class='lparen'>(</span><span class='symbol'>:group</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>standard</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>end</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="handle_argument_error-instance_method"> #<strong>handle_argument_error</strong>(command, error, args, arity) &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("handle_argument_error-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:handle_argument_error">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>:nodoc:</p> </div> </div> <div class="tags"> <p class="tag_title">Raises:</p> <ul class="raise"> <li> <span class='type'>(<tt><span class='object_link'><a href="/gems/thor/Thor/InvocationError" title="Thor::InvocationError (class)">InvocationError</a></span></tt>)</span> </li> </ul> </div><table class="source_code"> <tr> <td> <pre class="lines"> 618 619 620 621 622 623 624 625</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 618</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_argument_error'>handle_argument_error</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_error'>error</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='id identifier rubyid_arity'>arity</span><span class='rparen'>)</span> <span class='comment'>#:nodoc: </span> <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_ancestor_name'>ancestor_name</span><span class='comma'>,</span> <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'> </span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='id identifier rubyid_msg'>msg</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>ERROR: \&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_basename'>basename</span><span class='embexpr_end'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'>\&quot; was called with </span><span class='tstring_end'>&quot;</span></span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span> <span class='id identifier rubyid_msg'>msg</span> <span class='op'>&lt;&lt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>no arguments</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='id identifier rubyid_msg'>msg</span> <span class='op'>&lt;&lt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>arguments </span><span class='tstring_end'>&quot;</span></span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span> <span class='kw'>unless</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='id identifier rubyid_msg'>msg</span> <span class='op'>&lt;&lt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\nUsage: \&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_banner'>banner</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\&quot;\n \&quot;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>\&quot;</span><span class='tstring_end'>&quot;</span></span> <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="/gems/thor/Thor/InvocationError" title="Thor::InvocationError (class)">InvocationError</a></span></span><span class='comma'>,</span> <span class='id identifier rubyid_msg'>msg</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="handle_no_command_error-instance_method"> #<strong>handle_no_command_error</strong>(command, has_namespace = $thor_runner) &#x21d2; <tt>Object</tt> <span class="aliases">Also known as: <span class="names"><span id='handle_no_task_error-instance_method'>handle_no_task_error</span></span> </span> </h3><script> $(document.getElementById("handle_no_command_error-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:handle_no_command_error">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>:nodoc:</p> </div> </div> <div class="tags"> <p class="tag_title">Raises:</p> <ul class="raise"> <li> <span class='type'>(<tt><span class='object_link'><a href="/gems/thor/Thor/UndefinedCommandError" title="Thor::UndefinedCommandError (class)">UndefinedCommandError</a></span></tt>)</span> </li> </ul> </div><table class="source_code"> <tr> <td> <pre class="lines"> 613 614 615</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 613</span> <span class='kw'>def</span> <span class='id identifier rubyid_handle_no_command_error'>handle_no_command_error</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_has_namespace'>has_namespace</span> <span class='op'>=</span> <span class='gvar'>$thor_runner</span><span class='rparen'>)</span> <span class='comment'>#:nodoc: </span> <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="/gems/thor/Thor/UndefinedCommandError" title="Thor::UndefinedCommandError (class)">UndefinedCommandError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="/gems/thor/Thor/UndefinedCommandError#initialize-instance_method" title="Thor::UndefinedCommandError#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_all_commands'>all_commands</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='comma'>,</span> <span class='lparen'>(</span><span class='id identifier rubyid_namespace'>namespace</span> <span class='kw'>if</span> <span class='id identifier rubyid_has_namespace'>has_namespace</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="namespace-instance_method"> #<strong>namespace</strong>(name = nil) &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("namespace-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:namespace">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>Sets the namespace for the Thor or Thor::Group class. By default the namespace is retrieved from the class name. If your Thor class is named Scripts::MyScript, the help method, for example, will be called as:</p> <pre class="code ruby"><code class="ruby">thor scripts:my_script -h </code></pre> <p>If you change the namespace:</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_namespace'>namespace</span> <span class='symbol'>:my_scripts</span> </code></pre> <p>You change how your commands are invoked:</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_thor'>thor</span> <span class='id identifier rubyid_my_scripts'>my_scripts</span> <span class='op'>-</span><span class='id identifier rubyid_h'>h</span> </code></pre> <p>Finally, if you change your namespace to default:</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_namespace'>namespace</span> <span class='symbol'>:default</span> </code></pre> <p>Your commands can be invoked with a shortcut. Instead of:</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_thor'>thor</span> <span class='symbol'>:my_command</span> </code></pre> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 566 567 568 569 570 571 572</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 566</span> <span class='kw'>def</span> <span class='id identifier rubyid_namespace'>namespace</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_name'>name</span> <span class='ivar'>@namespace</span> <span class='op'>=</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='kw'>else</span> <span class='ivar'>@namespace</span> <span class='op'>||=</span> <span class='const'><span class='object_link'><a href="/gems/thor/Thor" title="Thor (class)">Thor</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="/gems/thor/Thor/Util" title="Thor::Util (module)">Util</a></span></span><span class='period'>.</span><span class='id identifier rubyid_namespace_from_thor_class'><span class='object_link'><a href="/gems/thor/Thor/Util#namespace_from_thor_class-class_method" title="Thor::Util.namespace_from_thor_class (method)">namespace_from_thor_class</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span> <span class='kw'>end</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="no_commands-instance_method"> #<strong>no_commands</strong>(&amp;block) &#x21d2; <tt>Object</tt> <span class="aliases">Also known as: <span class="names"><span id='no_tasks-instance_method'>no_tasks</span></span> </span> </h3><script> $(document.getElementById("no_commands-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:no_commands">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>All methods defined inside the given block are not added as commands.</p> <p>So you can do:</p> <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>MyScript</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="/gems/thor/Thor" title="Thor (class)">Thor</a></span></span> <span class='id identifier rubyid_no_commands'>no_commands</span> <span class='kw'>do</span> <span class='kw'>def</span> <span class='id identifier rubyid_this_is_not_a_command'>this_is_not_a_command</span> <span class='kw'>end</span> <span class='kw'>end</span> <span class='kw'>end</span> </code></pre> <p>You can also add the method and remove it from the command list:</p> <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>MyScript</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="/gems/thor/Thor" title="Thor (class)">Thor</a></span></span> <span class='kw'>def</span> <span class='id identifier rubyid_this_is_not_a_command'>this_is_not_a_command</span> <span class='kw'>end</span> <span class='id identifier rubyid_remove_command'>remove_command</span> <span class='symbol'>:this_is_not_a_command</span> <span class='kw'>end</span> </code></pre> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 530 531 532</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 530</span> <span class='kw'>def</span> <span class='id identifier rubyid_no_commands'>no_commands</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> <span class='id identifier rubyid_no_commands_context'>no_commands_context</span><span class='period'>.</span><span class='id identifier rubyid_enter'>enter</span><span class='lparen'>(</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="no_commands?-instance_method"> #<strong>no_commands?</strong> &#x21d2; <tt>Boolean</tt> </h3><script> $(document.getElementById("no_commands?-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:no_commands%3F">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> </div> </div> <div class="tags"> <p class="tag_title">Returns:</p> <ul class="return"> <li> <span class='type'>(<tt>Boolean</tt>)</span> </li> </ul> </div><table class="source_code"> <tr> <td> <pre class="lines"> 540 541 542</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 540</span> <span class='kw'>def</span> <span class='id identifier rubyid_no_commands?'>no_commands?</span> <span class='id identifier rubyid_no_commands_context'>no_commands_context</span><span class='period'>.</span><span class='id identifier rubyid_entered?'>entered?</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="no_commands_context-instance_method"> #<strong>no_commands_context</strong> &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("no_commands_context-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:no_commands_context">permalink</a>'); </script> <table class="source_code"> <tr> <td> <pre class="lines"> 536 537 538</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 536</span> <span class='kw'>def</span> <span class='id identifier rubyid_no_commands_context'>no_commands_context</span> <span class='ivar'>@no_commands_context</span> <span class='op'>||=</span> <span class='const'><span class='object_link'><a href="/gems/thor/Thor/NestedContext" title="Thor::NestedContext (class)">NestedContext</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="/gems/thor/Thor/NestedContext#initialize-instance_method" title="Thor::NestedContext#initialize (method)">new</a></span></span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="public_command-instance_method"> #<strong>public_command</strong>(*names) &#x21d2; <tt>Object</tt> <span class="aliases">Also known as: <span class="names"><span id='public_task-instance_method'>public_task</span></span> </span> </h3><script> $(document.getElementById("public_command-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:public_command">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>Allows to use private methods from parent in child classes as commands.</p> <h4 id="label-Parameters">Parameters</h4> <pre class="code ruby"><code class="ruby">names&lt;Array&gt;:: Method names to be used as commands </code></pre> <h4 id="label-Examples">Examples</h4> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_public_command'>public_command</span> <span class='symbol'>:foo</span> <span class='id identifier rubyid_public_command'>public_command</span> <span class='symbol'>:foo</span><span class='comma'>,</span> <span class='symbol'>:bar</span><span class='comma'>,</span> <span class='symbol'>:baz</span> </code></pre> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 606 607 608 609 610</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 606</span> <span class='kw'>def</span> <span class='id identifier rubyid_public_command'>public_command</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_names'>names</span><span class='rparen'>)</span> <span class='id identifier rubyid_names'>names</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_name'>name</span><span class='op'>|</span> <span class='id identifier rubyid_class_eval'>class_eval</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>def </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'>(*); super end</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='kw'>__FILE__</span><span class='comma'>,</span> <span class='kw'>__LINE__</span> <span class='kw'>end</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="remove_argument-instance_method"> #<strong>remove_argument</strong>(*names) &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("remove_argument-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:remove_argument">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>Removes a previous defined argument. If :undefine is given, undefine accessors as well.</p> <h4 id="label-Parameters">Parameters</h4> <dl class="rdoc-list note-list"><dt>names&lt;Array&gt; <dd> <p>Arguments to be removed</p> </dd></dl> <h4 id="label-Examples">Examples</h4> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_remove_argument'>remove_argument</span> <span class='symbol'>:foo</span> <span class='id identifier rubyid_remove_argument'>remove_argument</span> <span class='symbol'>:foo</span><span class='comma'>,</span> <span class='symbol'>:bar</span><span class='comma'>,</span> <span class='symbol'>:baz</span><span class='comma'>,</span> <span class='symbol'>:undefine</span> <span class='op'>=&gt;</span> <span class='kw'>true</span> </code></pre> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 426 427 428 429 430 431 432 433</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 426</span> <span class='kw'>def</span> <span class='id identifier rubyid_remove_argument'>remove_argument</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_names'>names</span><span class='rparen'>)</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_names'>names</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_names'>names</span><span class='period'>.</span><span class='id identifier rubyid_pop'>pop</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='id identifier rubyid_names'>names</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_name'>name</span><span class='op'>|</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_delete_if'>delete_if</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='op'>|</span> <span class='id identifier rubyid_a'>a</span><span class='period'>.</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_to_s'>to_s</span> <span class='rbrace'>}</span> <span class='id identifier rubyid_undef_method'>undef_method</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:undefine</span><span class='rbracket'>]</span> <span class='kw'>end</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="remove_class_option-instance_method"> #<strong>remove_class_option</strong>(*names) &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("remove_class_option-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:remove_class_option">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>Removes a previous defined class option.</p> <h4 id="label-Parameters">Parameters</h4> <dl class="rdoc-list note-list"><dt>names&lt;Array&gt; <dd> <p>Class options to be removed</p> </dd></dl> <h4 id="label-Examples">Examples</h4> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_remove_class_option'>remove_class_option</span> <span class='symbol'>:foo</span> <span class='id identifier rubyid_remove_class_option'>remove_class_option</span> <span class='symbol'>:foo</span><span class='comma'>,</span> <span class='symbol'>:bar</span><span class='comma'>,</span> <span class='symbol'>:baz</span> </code></pre> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 445 446 447 448 449</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 445</span> <span class='kw'>def</span> <span class='id identifier rubyid_remove_class_option'>remove_class_option</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_names'>names</span><span class='rparen'>)</span> <span class='id identifier rubyid_names'>names</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_name'>name</span><span class='op'>|</span> <span class='id identifier rubyid_class_options'>class_options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span> <span class='kw'>end</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="remove_command-instance_method"> #<strong>remove_command</strong>(*names) &#x21d2; <tt>Object</tt> <span class="aliases">Also known as: <span class="names"><span id='remove_task-instance_method'>remove_task</span></span> </span> </h3><script> $(document.getElementById("remove_command-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:remove_command">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>Removes a given command from this Thor class. This is usually done if you are inheriting from another class and don’t want it to be available anymore.</p> <p>By default it only remove the mapping to the command. But you can supply :undefine =&gt; true to undefine the method from the class as well.</p> <h4 id="label-Parameters">Parameters</h4> <dl class="rdoc-list note-list"><dt>name&lt;Symbol|String&gt; <dd> <p>The name of the command to be removed</p> </dd><dt>options&lt;Hash&gt; <dd> <p>You can give :undefine =&gt; true if you want commands the method to be undefined from the class as well.</p> </dd></dl> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 500 501 502 503 504 505 506 507 508</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 500</span> <span class='kw'>def</span> <span class='id identifier rubyid_remove_command'>remove_command</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_names'>names</span><span class='rparen'>)</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_names'>names</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_names'>names</span><span class='period'>.</span><span class='id identifier rubyid_pop'>pop</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='id identifier rubyid_names'>names</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_name'>name</span><span class='op'>|</span> <span class='id identifier rubyid_commands'>commands</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</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='rparen'>)</span> <span class='id identifier rubyid_all_commands'>all_commands</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</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='rparen'>)</span> <span class='id identifier rubyid_undef_method'>undef_method</span> <span class='id identifier rubyid_name'>name</span> <span class='kw'>if</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:undefine</span><span class='rbracket'>]</span> <span class='kw'>end</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="start-instance_method"> #<strong>start</strong>(given_args = ARGV, config = {}) &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("start-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:start">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>Parses the command and options from the given args, instantiate the class and invoke the command. This method is used when the arguments must be parsed from an array. If you are inside Ruby and want to use a Thor class, you can simply initialize it:</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_script'>script</span> <span class='op'>=</span> <span class='const'>MyScript</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_config'>config</span><span class='rparen'>)</span> <span class='id identifier rubyid_script'>script</span><span class='period'>.</span><span class='id identifier rubyid_invoke'>invoke</span><span class='lparen'>(</span><span class='symbol'>:command</span><span class='comma'>,</span> <span class='id identifier rubyid_first_arg'>first_arg</span><span class='comma'>,</span> <span class='id identifier rubyid_second_arg'>second_arg</span><span class='comma'>,</span> <span class='id identifier rubyid_third_arg'>third_arg</span><span class='rparen'>)</span> </code></pre> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 582 583 584 585 586 587 588 589 590 591 592 593 594</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 582</span> <span class='kw'>def</span> <span class='id identifier rubyid_start'>start</span><span class='lparen'>(</span><span class='id identifier rubyid_given_args'>given_args</span> <span class='op'>=</span> <span class='const'>ARGV</span><span class='comma'>,</span> <span class='id identifier rubyid_config'>config</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:shell</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='const'><span class='object_link'><a href="/gems/thor/Thor" title="Thor (class)">Thor</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="/gems/thor/Thor/Base" title="Thor::Base (module)">Base</a></span></span><span class='period'>.</span><span class='id identifier rubyid_shell'><span class='object_link'><a href="/gems/thor/Thor/Base#shell-class_method" title="Thor::Base.shell (method)">shell</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='id identifier rubyid_dispatch'>dispatch</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_given_args'>given_args</span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_config'>config</span><span class='rparen'>)</span> <span class='kw'>rescue</span> <span class='const'><span class='object_link'><a href="/gems/thor/Thor" title="Thor (class)">Thor</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="/gems/thor/Thor/Error" title="Thor::Error (class)">Error</a></span></span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:debug</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>THOR_DEBUG</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>1</span><span class='tstring_end'>&quot;</span></span> <span class='op'>?</span> <span class='lparen'>(</span><span class='id identifier rubyid_raise'>raise</span> <span class='id identifier rubyid_e'>e</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:shell</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span> <span class='id identifier rubyid_exit'>exit</span><span class='lparen'>(</span><span class='kw'>false</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_exit_on_failure?'>exit_on_failure?</span> <span class='kw'>rescue</span> <span class='const'>Errno</span><span class='op'>::</span><span class='const'>EPIPE</span> <span class='comment'># This happens if a thor command is piped to something like `head`, </span> <span class='comment'># which closes the pipe when it&#39;s done reading. This will also </span> <span class='comment'># mean that if the pipe is closed, further unnecessary </span> <span class='comment'># computation will not occur. </span> <span class='id identifier rubyid_exit'>exit</span><span class='lparen'>(</span><span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="stop_on_unknown_option?-instance_method"> #<strong>stop_on_unknown_option?</strong>(command_name) &#x21d2; <tt>Boolean</tt> </h3><script> $(document.getElementById("stop_on_unknown_option?-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:stop_on_unknown_option%3F">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>If true, option parsing is suspended as soon as an unknown option or a regular argument is encountered. All remaining arguments are passed to the command as regular arguments.</p> </div> </div> <div class="tags"> <p class="tag_title">Returns:</p> <ul class="return"> <li> <span class='type'>(<tt>Boolean</tt>)</span> </li> </ul> </div><table class="source_code"> <tr> <td> <pre class="lines"> 201 202 203</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 201</span> <span class='kw'>def</span> <span class='id identifier rubyid_stop_on_unknown_option?'>stop_on_unknown_option?</span><span class='lparen'>(</span><span class='id identifier rubyid_command_name'>command_name</span><span class='rparen'>)</span> <span class='comment'>#:nodoc: </span> <span class='kw'>false</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="strict_args_position-instance_method"> #<strong>strict_args_position</strong> &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("strict_args_position-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:strict_args_position">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>:nodoc:</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 218 219 220</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 218</span> <span class='kw'>def</span> <span class='id identifier rubyid_strict_args_position'>strict_args_position</span> <span class='comment'>#:nodoc: </span> <span class='ivar'>@strict_args_position</span> <span class='op'>||=</span> <span class='id identifier rubyid_from_superclass'>from_superclass</span><span class='lparen'>(</span><span class='symbol'>:strict_args_position</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="strict_args_position!-instance_method"> #<strong>strict_args_position!</strong> &#x21d2; <tt>Object</tt> </h3><script> $(document.getElementById("strict_args_position!-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:strict_args_position!">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>If you want only strict string args (useful when cascading thor classes), call strict_args_position! This is disabled by default to allow dynamic invocations.</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 214 215 216</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 214</span> <span class='kw'>def</span> <span class='id identifier rubyid_strict_args_position!'>strict_args_position!</span> <span class='ivar'>@strict_args_position</span> <span class='op'>=</span> <span class='kw'>true</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> <h3 class="signature " id="strict_args_position?-instance_method"> #<strong>strict_args_position?</strong>(config) &#x21d2; <tt>Boolean</tt> </h3><script> $(document.getElementById("strict_args_position?-instance_method")).prepend( '<a class="permalink" href="/gems/thor/Thor%2FBase%2FClassMethods:strict_args_position%3F">permalink</a>'); </script> <div class="docstring"> <div class="discussion"> <p>:nodoc:</p> </div> </div> <div class="tags"> <p class="tag_title">Returns:</p> <ul class="return"> <li> <span class='type'>(<tt>Boolean</tt>)</span> </li> </ul> </div><table class="source_code"> <tr> <td> <pre class="lines"> 222 223 224</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/thor/base.rb', line 222</span> <span class='kw'>def</span> <span class='id identifier rubyid_strict_args_position?'>strict_args_position?</span><span class='lparen'>(</span><span class='id identifier rubyid_config'>config</span><span class='rparen'>)</span> <span class='comment'>#:nodoc: </span> <span class='op'>!</span><span class='op'>!</span><span class='id identifier rubyid_strict_args_position'>strict_args_position</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> </div> </div> <div id="footer"> Generated on Sun Nov 24 05:04:47 2024 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.36 (ruby-3.3.5). </div> <script> window.yard_library_name = 'thor'; window.yard_library_version = '1.3.2'; </script> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-7172246-5', 'auto'); ga('send', 'pageview'); </script> </div> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10