docs/Bovem/Application.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Class: Bovem::Application
— Documentation by YARD 0.9.7
</title>
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
<script type="text/javascript" charset="utf-8">
pathId = "Bovem::Application";
relpath = '../';
</script>
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
</head>
<body>
<div class="nav_wrap">
<iframe id="nav" src="../class_list.html?1"></iframe>
<div id="resizer"></div>
</div>
<div id="main" tabindex="-1">
<div id="header">
<div id="menu">
<a href="../_index.html">Index (A)</a> »
<span class='title'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span>
»
<span class="title">Application</span>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="../class_list.html">
<svg width="24" height="24">
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
</svg>
</a>
</div>
<div class="clear"></div>
</div>
<div id="content"><h1>Class: Bovem::Application
</h1>
<div class="box_info">
<dl>
<dt>Inherits:</dt>
<dd>
<span class="inheritName"><span class='object_link'><a href="Command.html" title="Bovem::Command (class)">Command</a></span></span>
<ul class="fullTree">
<li>Object</li>
<li class="next"><span class='object_link'><a href="Command.html" title="Bovem::Command (class)">Command</a></span></li>
<li class="next">Bovem::Application</li>
</ul>
<a href="#" class="inheritanceTree">show all</a>
</dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/bovem/application.rb</dd>
</dl>
</div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>This is the main class for a Bovem application.</p>
<p>Basically is the same of a command, but it adds support for application version.</p>
</div>
</div>
<div class="tags">
</div>
<h2>Constant Summary</h2>
<dl class="constants">
<dt id="LOCALE_ROOT-constant" class="">LOCALE_ROOT =
<div class="docstring">
<div class="discussion">
<p>The location of the locales translation files.</p>
</div>
</div>
<div class="tags">
</div>
</dt>
<dd><pre class="code"><span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='lparen'>(</span><span class='kw'>__FILE__</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/../../locales/</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
</dl>
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#console-instance_method" title="#console (instance method)">#<strong>console</strong> ⇒ Bovem::Console </a>
</span>
<span class="summary_desc"><div class='inline'><p>A console helper.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#output_commands-instance_method" title="#output_commands (instance method)">#<strong>output_commands</strong> ⇒ Boolean </a>
</span>
<span class="summary_desc"><div class='inline'><p>If to show the output of the commands run via <span class='object_link'><a href="#run-instance_method" title="Bovem::Application#run (method)">#run</a></span>.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#shell-instance_method" title="#shell (instance method)">#<strong>shell</strong> ⇒ Bovem::Shell </a>
</span>
<span class="summary_desc"><div class='inline'><p>A shell helper.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#show_commands-instance_method" title="#show_commands (instance method)">#<strong>show_commands</strong> ⇒ Boolean </a>
</span>
<span class="summary_desc"><div class='inline'><p>If to show command lines run via <span class='object_link'><a href="#run-instance_method" title="Bovem::Application#run (method)">#run</a></span>.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#skip_commands-instance_method" title="#skip_commands (instance method)">#<strong>skip_commands</strong> ⇒ Boolean </a>
</span>
<span class="summary_desc"><div class='inline'><p>If to skip commands run via <span class='object_link'><a href="#run-instance_method" title="Bovem::Application#run (method)">#run</a></span>.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#version-instance_method" title="#version (instance method)">#<strong>version</strong>(value = nil) ⇒ String|nil </a>
</span>
<span class="summary_desc"><div class='inline'><p>Reads and optionally sets the version of this application.</p>
</div></span>
</li>
</ul>
<h3 class="inherited">Attributes inherited from <span class='object_link'><a href="Command.html" title="Bovem::Command (class)">Command</a></span></h3>
<p class="inherited"><span class='object_link'><a href="Command.html#action-instance_method" title="Bovem::Command#action (method)">#action</a></span>, <span class='object_link'><a href="Command.html#after-instance_method" title="Bovem::Command#after (method)">#after</a></span>, <span class='object_link'><a href="Command.html#application-instance_method" title="Bovem::Command#application (method)">#application</a></span>, <span class='object_link'><a href="Command.html#arguments-instance_method" title="Bovem::Command#arguments (method)">#arguments</a></span>, <span class='object_link'><a href="Command.html#banner-instance_method" title="Bovem::Command#banner (method)">#banner</a></span>, <span class='object_link'><a href="Command.html#before-instance_method" title="Bovem::Command#before (method)">#before</a></span>, <span class='object_link'><a href="Command.html#commands-instance_method" title="Bovem::Command#commands (method)">#commands</a></span>, <span class='object_link'><a href="Command.html#description-instance_method" title="Bovem::Command#description (method)">#description</a></span>, <span class='object_link'><a href="Command.html#i18n-instance_method" title="Bovem::Command#i18n (method)">#i18n</a></span>, <span class='object_link'><a href="Command.html#name-instance_method" title="Bovem::Command#name (method)">#name</a></span>, <span class='object_link'><a href="Command.html#options-instance_method" title="Bovem::Command#options (method)">#options</a></span>, <span class='object_link'><a href="Command.html#parent-instance_method" title="Bovem::Command#parent (method)">#parent</a></span>, <span class='object_link'><a href="Command.html#synopsis-instance_method" title="Bovem::Command#synopsis (method)">#synopsis</a></span></p>
<h3 class="inherited">Attributes included from <span class='object_link'><a href="CommandMethods/Children.html" title="Bovem::CommandMethods::Children (module)">CommandMethods::Children</a></span></h3>
<p class="inherited"><span class='object_link'><a href="CommandMethods/Children.html#commands-instance_method" title="Bovem::CommandMethods::Children#commands (method)">#commands</a></span>, <span class='object_link'><a href="CommandMethods/Children.html#options-instance_method" title="Bovem::CommandMethods::Children#options (method)">#options</a></span></p>
<h2>
Class Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#create-class_method" title="create (class method)">.<strong>create</strong>(options = {}, &block) ⇒ Application </a>
</span>
<span class="summary_desc"><div class='inline'><p>Initializes a new Bovem application.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#create_application-class_method" title="create_application (class method)">.<strong>create_application</strong>(run, args, options, &block) ⇒ Application </a>
</span>
<span class="summary_desc"><div class='inline'><p>Create the application.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#setup_application_option-class_method" title="setup_application_option (class method)">.<strong>setup_application_option</strong>(options) ⇒ Array </a>
</span>
<span class="summary_desc"><div class='inline'><p>Setup options for application creation.</p>
</div></span>
</li>
</ul>
<h2>
Instance Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#command_help-instance_method" title="#command_help (instance method)">#<strong>command_help</strong>(command) ⇒ Object </a>
</span>
<span class="summary_desc"><div class='inline'><p>Shows a help about a command.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#executable_name-instance_method" title="#executable_name (instance method)">#<strong>executable_name</strong> ⇒ String </a>
</span>
<span class="summary_desc"><div class='inline'><p>The name of the current executable.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#execute-instance_method" title="#execute (instance method)">#<strong>execute</strong>(args = nil) ⇒ Object </a>
</span>
<span class="summary_desc"><div class='inline'><p>Executes this application.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#help_option-instance_method" title="#help_option (instance method)">#<strong>help_option</strong> ⇒ Object </a>
</span>
<span class="summary_desc"><div class='inline'><p>Adds a help command and a help option to this application.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(options = {}, &block) ⇒ Application </a>
</span>
<span class="note title constructor">constructor</span>
<span class="summary_desc"><div class='inline'><p>Creates a new application.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#run-instance_method" title="#run (instance method)">#<strong>run</strong>(command, message = nil, show_exit = true, fatal = true) ⇒ Hash </a>
</span>
<span class="summary_desc"><div class='inline'><p>Runs a command into the shell.</p>
</div></span>
</li>
</ul>
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="Command.html" title="Bovem::Command (class)">Command</a></span></h3>
<p class="inherited"><span class='object_link'><a href="Command.html#application%3F-instance_method" title="Bovem::Command#application? (method)">#application?</a></span>, <span class='object_link'><a href="Command.html#banner%3F-instance_method" title="Bovem::Command#banner? (method)">#banner?</a></span>, <span class='object_link'><a href="Command.html#description%3F-instance_method" title="Bovem::Command#description? (method)">#description?</a></span>, <span class='object_link'><a href="Command.html#full_name-instance_method" title="Bovem::Command#full_name (method)">#full_name</a></span>, <span class='object_link'><a href="Command.html#setup_with-instance_method" title="Bovem::Command#setup_with (method)">#setup_with</a></span></p>
<h3 class="inherited">Methods included from <span class='object_link'><a href="CommandMethods/Children.html" title="Bovem::CommandMethods::Children (module)">CommandMethods::Children</a></span></h3>
<p class="inherited"><span class='object_link'><a href="CommandMethods/Children.html#argument-instance_method" title="Bovem::CommandMethods::Children#argument (method)">#argument</a></span>, <span class='object_link'><a href="CommandMethods/Children.html#arguments-instance_method" title="Bovem::CommandMethods::Children#arguments (method)">#arguments</a></span>, <span class='object_link'><a href="CommandMethods/Children.html#clear_commands-instance_method" title="Bovem::CommandMethods::Children#clear_commands (method)">#clear_commands</a></span>, <span class='object_link'><a href="CommandMethods/Children.html#clear_options-instance_method" title="Bovem::CommandMethods::Children#clear_options (method)">#clear_options</a></span>, <span class='object_link'><a href="CommandMethods/Children.html#command-instance_method" title="Bovem::CommandMethods::Children#command (method)">#command</a></span>, <span class='object_link'><a href="CommandMethods/Children.html#commands%3F-instance_method" title="Bovem::CommandMethods::Children#commands? (method)">#commands?</a></span>, <span class='object_link'><a href="CommandMethods/Children.html#get_options-instance_method" title="Bovem::CommandMethods::Children#get_options (method)">#get_options</a></span>, <span class='object_link'><a href="CommandMethods/Children.html#option-instance_method" title="Bovem::CommandMethods::Children#option (method)">#option</a></span>, <span class='object_link'><a href="CommandMethods/Children.html#options%3F-instance_method" title="Bovem::CommandMethods::Children#options? (method)">#options?</a></span></p>
<h3 class="inherited">Methods included from <span class='object_link'><a href="CommandMethods/Help.html" title="Bovem::CommandMethods::Help (module)">CommandMethods::Help</a></span></h3>
<p class="inherited"><span class='object_link'><a href="CommandMethods/Help.html#show_help-instance_method" title="Bovem::CommandMethods::Help#show_help (method)">#show_help</a></span></p>
<div id="constructor_details" class="method_details_list">
<h2>Constructor Details</h2>
<div class="method_details first">
<h3 class="signature first" id="initialize-instance_method">
#<strong>initialize</strong>(options = {}, &block) ⇒ <tt><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Creates a new application.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>options</span>
<span class='type'>(<tt>Hash</tt>)</span>
<em class="default">(defaults to: <tt>{}</tt>)</em>
—
<div class='inline'><p>The settings to initialize the application with.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
90
91
92
93
94
95
96
97
98
99
100</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 90</span>
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='ivar'>@shell</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Shell.html" title="Bovem::Shell (class)">Shell</a></span></span><span class='period'>.</span><span class='id identifier rubyid_instance'><span class='object_link'><a href="Shell.html#instance-class_method" title="Bovem::Shell.instance (method)">instance</a></span></span>
<span class='ivar'>@console</span> <span class='op'>=</span> <span class='ivar'>@shell</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span>
<span class='ivar'>@skip_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='ivar'>@show_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='ivar'>@output_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='id identifier rubyid_help_option'>help_option</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="instance_attr_details" class="attr_details">
<h2>Instance Attribute Details</h2>
<span id="console=-instance_method"></span>
<div class="method_details first">
<h3 class="signature first" id="console-instance_method">
#<strong>console</strong> ⇒ <tt><span class='object_link'><a href="Console.html" title="Bovem::Console (class)">Bovem::Console</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns A console helper.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="Console.html" title="Bovem::Console (class)">Bovem::Console</a></span></tt>)</span>
—
<div class='inline'><p>A console helper.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 24</span>
<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></span> <span class='op'><</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Command.html" title="Bovem::Command (class)">Command</a></span></span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:version</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:shell</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:console</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:skip_commands</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:show_commands</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:output_commands</span>
<span class='comment'># The location of the locales translation files.
</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='lparen'>(</span><span class='kw'>__FILE__</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/../../locales/</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
<span class='comment'># Initializes a new Bovem application.
</span> <span class='comment'>#
</span> <span class='comment'># In options, you can override the command line arguments with `:__args__`, and you can skip execution by specifying `run: false`.
</span> <span class='comment'>#
</span> <span class='comment'># @see Command#setup_with
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
</span> <span class='comment'># @return [Application] The created application.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>unless</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span>
<span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></span><span class='comma'>,</span> <span class='symbol'>:missing_block</span><span class='comma'>,</span>
<span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="I18n.html" title="Bovem::I18n (class)">I18n</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:locale</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>root:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>bovem.application</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>path:</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_missing_app_block'>missing_app_block</span>
<span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_run'>run</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_setup_application_option'>setup_application_option</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
<span class='kw'>begin</span>
<span class='id identifier rubyid_create_application'>create_application</span><span class='lparen'>(</span><span class='id identifier rubyid_run'>run</span><span class='comma'>,</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='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>rescue</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
<span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
<span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_exit'>exit</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='comment'># Setup options for application creation.
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The options to setups.
</span> <span class='comment'># @return [Array] If to run the application, the arguments and the specified options.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_setup_application_option'>setup_application_option</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
<span class='id identifier rubyid_base_options'>base_options</span> <span class='op'>=</span> <span class='lbrace'>{</span>
<span class='label'>name:</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="I18n.html" title="Bovem::I18n (class)">I18n</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:locale</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>root:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>bovem.application</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>path:</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_default_application_name'>default_application_name</span><span class='comma'>,</span>
<span class='label'>parent:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>application:</span> <span class='kw'>nil</span>
<span class='rbrace'>}</span>
<span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_base_options'>base_options</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='rparen'>)</span>
<span class='id identifier rubyid_run'>run</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:run</span><span class='rparen'>)</span>
<span class='lbracket'>[</span><span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_run'>run</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>?</span> <span class='id identifier rubyid_run'>run</span> <span class='op'>:</span> <span class='kw'>true</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_boolean'>to_boolean</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:__args__</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rbracket'>]</span>
<span class='kw'>end</span>
<span class='comment'># Create the application.
</span> <span class='comment'>#
</span> <span class='comment'># @param run [Boolean] If to run the application.
</span> <span class='comment'># @param args [Hash] The arguments to use for running.
</span> <span class='comment'># @param options [Hash] The options of the application.
</span> <span class='comment'># @return [Application] The new application.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create_application'>create_application</span><span class='lparen'>(</span><span class='id identifier rubyid_run'>run</span><span class='comma'>,</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='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_application'>application</span> <span class='op'>=</span> <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_application'>application</span> <span class='op'>&&</span> <span class='id identifier rubyid_run'>run</span>
<span class='id identifier rubyid_application'>application</span>
<span class='kw'>end</span>
<span class='comment'># Creates a new application.
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='ivar'>@shell</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Shell.html" title="Bovem::Shell (class)">Shell</a></span></span><span class='period'>.</span><span class='id identifier rubyid_instance'><span class='object_link'><a href="Shell.html#instance-class_method" title="Bovem::Shell.instance (method)">instance</a></span></span>
<span class='ivar'>@console</span> <span class='op'>=</span> <span class='ivar'>@shell</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span>
<span class='ivar'>@skip_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='ivar'>@show_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='ivar'>@output_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='id identifier rubyid_help_option'>help_option</span>
<span class='kw'>end</span>
<span class='comment'># Reads and optionally sets the version of this application.
</span> <span class='comment'>#
</span> <span class='comment'># @param value [String|nil] The new version of this application.
</span> <span class='comment'># @return [String|nil] The version of this application.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_version'>version</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='ivar'>@version</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='ivar'>@version</span>
<span class='kw'>end</span>
<span class='comment'># Executes this application.
</span> <span class='comment'>#
</span> <span class='comment'># @param args [Array] The command line to pass to this application. Defaults to `ARGV`.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span> <span class='op'>||</span> <span class='const'>ARGV</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='comment'># Adds a help command and a help option to this application.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help_option'>help_option</span>
<span class='id identifier rubyid_command'>command</span><span class='lparen'>(</span><span class='symbol'>:help</span><span class='comma'>,</span> <span class='label'>description:</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_command_description'>help_command_description</span><span class='rparen'>)</span> <span class='kw'>do</span>
<span class='id identifier rubyid_action'>action</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_command'>command</span><span class='op'>|</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_command_help'>command_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_option'>option</span><span class='lparen'>(</span><span class='symbol'>:help</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_option_short_form'>help_option_short_form</span><span class='comma'>,</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_option_long_form'>help_option_long_form</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>help:</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_message'>help_message</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_application'>application</span><span class='comma'>,</span> <span class='id identifier rubyid__'>_</span><span class='op'>|</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span> <span class='rbrace'>}</span>
<span class='kw'>end</span>
<span class='comment'># The name of the current executable.
</span> <span class='comment'>#
</span> <span class='comment'># @return [String] The name of the current executable.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_executable_name'>executable_name</span>
<span class='gvar'>$PROGRAM_NAME</span>
<span class='kw'>end</span>
<span class='comment'># Shows a help about a command.
</span> <span class='comment'>#
</span> <span class='comment'># @param command [Command] The command to show help for.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_command_help'>command_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
<span class='id identifier rubyid_fetch_commands_for_help'>fetch_commands_for_help</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_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_arg'>arg</span><span class='op'>|</span>
<span class='comment'># Find the command across
</span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_find_command'>find_command</span><span class='lparen'>(</span><span class='id identifier rubyid_arg'>arg</span><span class='comma'>,</span> <span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='label'>args:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='kw'>break</span> <span class='kw'>unless</span> <span class='id identifier rubyid_next_command'>next_command</span>
<span class='id identifier rubyid_command'>command</span> <span class='op'>=</span> <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_commands'>commands</span><span class='lbracket'>[</span><span class='id identifier rubyid_next_command'>next_command</span><span class='lbracket'>[</span><span class='symbol'>:name</span><span class='rbracket'>]</span><span class='rbracket'>]</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span>
<span class='kw'>end</span>
<span class='comment'># Runs a command into the shell.
</span> <span class='comment'>#
</span> <span class='comment'># @param command [String] The string to run.
</span> <span class='comment'># @param message [String] A message to show before running.
</span> <span class='comment'># @param show_exit [Boolean] If show the exit status.
</span> <span class='comment'># @param fatal [Boolean] If quit in case of fatal errors.
</span> <span class='comment'># @return [Hash] An hash with `status` and `output` keys.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_show_exit'>show_exit</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='ivar'>@shell</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='op'>!</span><span class='ivar'>@skip_commands</span><span class='comma'>,</span> <span class='id identifier rubyid_show_exit'>show_exit</span><span class='comma'>,</span> <span class='ivar'>@output_commands</span><span class='comma'>,</span> <span class='ivar'>@show_commands</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_private'>private</span>
<span class='comment'># :nodoc:
</span> <span class='kw'>def</span> <span class='id identifier rubyid_fetch_commands_for_help'>fetch_commands_for_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
<span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span> <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>:</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:present?</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<span id="output_commands=-instance_method"></span>
<div class="method_details ">
<h3 class="signature " id="output_commands-instance_method">
#<strong>output_commands</strong> ⇒ <tt>Boolean</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns If to show the output of the commands run via <span class='object_link'><a href="#run-instance_method" title="Bovem::Application#run (method)">#run</a></span>.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p>If to show the output of the commands run via <span class='object_link'><a href="#run-instance_method" title="Bovem::Application#run (method)">#run</a></span>.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 24</span>
<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></span> <span class='op'><</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Command.html" title="Bovem::Command (class)">Command</a></span></span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:version</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:shell</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:console</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:skip_commands</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:show_commands</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:output_commands</span>
<span class='comment'># The location of the locales translation files.
</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='lparen'>(</span><span class='kw'>__FILE__</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/../../locales/</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
<span class='comment'># Initializes a new Bovem application.
</span> <span class='comment'>#
</span> <span class='comment'># In options, you can override the command line arguments with `:__args__`, and you can skip execution by specifying `run: false`.
</span> <span class='comment'>#
</span> <span class='comment'># @see Command#setup_with
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
</span> <span class='comment'># @return [Application] The created application.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>unless</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span>
<span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></span><span class='comma'>,</span> <span class='symbol'>:missing_block</span><span class='comma'>,</span>
<span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="I18n.html" title="Bovem::I18n (class)">I18n</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:locale</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>root:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>bovem.application</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>path:</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_missing_app_block'>missing_app_block</span>
<span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_run'>run</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_setup_application_option'>setup_application_option</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
<span class='kw'>begin</span>
<span class='id identifier rubyid_create_application'>create_application</span><span class='lparen'>(</span><span class='id identifier rubyid_run'>run</span><span class='comma'>,</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='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>rescue</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
<span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
<span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_exit'>exit</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='comment'># Setup options for application creation.
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The options to setups.
</span> <span class='comment'># @return [Array] If to run the application, the arguments and the specified options.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_setup_application_option'>setup_application_option</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
<span class='id identifier rubyid_base_options'>base_options</span> <span class='op'>=</span> <span class='lbrace'>{</span>
<span class='label'>name:</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="I18n.html" title="Bovem::I18n (class)">I18n</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:locale</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>root:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>bovem.application</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>path:</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_default_application_name'>default_application_name</span><span class='comma'>,</span>
<span class='label'>parent:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>application:</span> <span class='kw'>nil</span>
<span class='rbrace'>}</span>
<span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_base_options'>base_options</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='rparen'>)</span>
<span class='id identifier rubyid_run'>run</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:run</span><span class='rparen'>)</span>
<span class='lbracket'>[</span><span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_run'>run</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>?</span> <span class='id identifier rubyid_run'>run</span> <span class='op'>:</span> <span class='kw'>true</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_boolean'>to_boolean</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:__args__</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rbracket'>]</span>
<span class='kw'>end</span>
<span class='comment'># Create the application.
</span> <span class='comment'>#
</span> <span class='comment'># @param run [Boolean] If to run the application.
</span> <span class='comment'># @param args [Hash] The arguments to use for running.
</span> <span class='comment'># @param options [Hash] The options of the application.
</span> <span class='comment'># @return [Application] The new application.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create_application'>create_application</span><span class='lparen'>(</span><span class='id identifier rubyid_run'>run</span><span class='comma'>,</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='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_application'>application</span> <span class='op'>=</span> <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_application'>application</span> <span class='op'>&&</span> <span class='id identifier rubyid_run'>run</span>
<span class='id identifier rubyid_application'>application</span>
<span class='kw'>end</span>
<span class='comment'># Creates a new application.
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='ivar'>@shell</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Shell.html" title="Bovem::Shell (class)">Shell</a></span></span><span class='period'>.</span><span class='id identifier rubyid_instance'><span class='object_link'><a href="Shell.html#instance-class_method" title="Bovem::Shell.instance (method)">instance</a></span></span>
<span class='ivar'>@console</span> <span class='op'>=</span> <span class='ivar'>@shell</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span>
<span class='ivar'>@skip_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='ivar'>@show_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='ivar'>@output_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='id identifier rubyid_help_option'>help_option</span>
<span class='kw'>end</span>
<span class='comment'># Reads and optionally sets the version of this application.
</span> <span class='comment'>#
</span> <span class='comment'># @param value [String|nil] The new version of this application.
</span> <span class='comment'># @return [String|nil] The version of this application.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_version'>version</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='ivar'>@version</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='ivar'>@version</span>
<span class='kw'>end</span>
<span class='comment'># Executes this application.
</span> <span class='comment'>#
</span> <span class='comment'># @param args [Array] The command line to pass to this application. Defaults to `ARGV`.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span> <span class='op'>||</span> <span class='const'>ARGV</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='comment'># Adds a help command and a help option to this application.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help_option'>help_option</span>
<span class='id identifier rubyid_command'>command</span><span class='lparen'>(</span><span class='symbol'>:help</span><span class='comma'>,</span> <span class='label'>description:</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_command_description'>help_command_description</span><span class='rparen'>)</span> <span class='kw'>do</span>
<span class='id identifier rubyid_action'>action</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_command'>command</span><span class='op'>|</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_command_help'>command_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_option'>option</span><span class='lparen'>(</span><span class='symbol'>:help</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_option_short_form'>help_option_short_form</span><span class='comma'>,</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_option_long_form'>help_option_long_form</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>help:</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_message'>help_message</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_application'>application</span><span class='comma'>,</span> <span class='id identifier rubyid__'>_</span><span class='op'>|</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span> <span class='rbrace'>}</span>
<span class='kw'>end</span>
<span class='comment'># The name of the current executable.
</span> <span class='comment'>#
</span> <span class='comment'># @return [String] The name of the current executable.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_executable_name'>executable_name</span>
<span class='gvar'>$PROGRAM_NAME</span>
<span class='kw'>end</span>
<span class='comment'># Shows a help about a command.
</span> <span class='comment'>#
</span> <span class='comment'># @param command [Command] The command to show help for.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_command_help'>command_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
<span class='id identifier rubyid_fetch_commands_for_help'>fetch_commands_for_help</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_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_arg'>arg</span><span class='op'>|</span>
<span class='comment'># Find the command across
</span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_find_command'>find_command</span><span class='lparen'>(</span><span class='id identifier rubyid_arg'>arg</span><span class='comma'>,</span> <span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='label'>args:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='kw'>break</span> <span class='kw'>unless</span> <span class='id identifier rubyid_next_command'>next_command</span>
<span class='id identifier rubyid_command'>command</span> <span class='op'>=</span> <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_commands'>commands</span><span class='lbracket'>[</span><span class='id identifier rubyid_next_command'>next_command</span><span class='lbracket'>[</span><span class='symbol'>:name</span><span class='rbracket'>]</span><span class='rbracket'>]</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span>
<span class='kw'>end</span>
<span class='comment'># Runs a command into the shell.
</span> <span class='comment'>#
</span> <span class='comment'># @param command [String] The string to run.
</span> <span class='comment'># @param message [String] A message to show before running.
</span> <span class='comment'># @param show_exit [Boolean] If show the exit status.
</span> <span class='comment'># @param fatal [Boolean] If quit in case of fatal errors.
</span> <span class='comment'># @return [Hash] An hash with `status` and `output` keys.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_show_exit'>show_exit</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='ivar'>@shell</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='op'>!</span><span class='ivar'>@skip_commands</span><span class='comma'>,</span> <span class='id identifier rubyid_show_exit'>show_exit</span><span class='comma'>,</span> <span class='ivar'>@output_commands</span><span class='comma'>,</span> <span class='ivar'>@show_commands</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_private'>private</span>
<span class='comment'># :nodoc:
</span> <span class='kw'>def</span> <span class='id identifier rubyid_fetch_commands_for_help'>fetch_commands_for_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
<span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span> <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>:</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:present?</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<span id="shell=-instance_method"></span>
<div class="method_details ">
<h3 class="signature " id="shell-instance_method">
#<strong>shell</strong> ⇒ <tt><span class='object_link'><a href="Shell.html" title="Bovem::Shell (class)">Bovem::Shell</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns A shell helper.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="Shell.html" title="Bovem::Shell (class)">Bovem::Shell</a></span></tt>)</span>
—
<div class='inline'><p>A shell helper.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 24</span>
<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></span> <span class='op'><</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Command.html" title="Bovem::Command (class)">Command</a></span></span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:version</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:shell</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:console</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:skip_commands</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:show_commands</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:output_commands</span>
<span class='comment'># The location of the locales translation files.
</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='lparen'>(</span><span class='kw'>__FILE__</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/../../locales/</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
<span class='comment'># Initializes a new Bovem application.
</span> <span class='comment'>#
</span> <span class='comment'># In options, you can override the command line arguments with `:__args__`, and you can skip execution by specifying `run: false`.
</span> <span class='comment'>#
</span> <span class='comment'># @see Command#setup_with
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
</span> <span class='comment'># @return [Application] The created application.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>unless</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span>
<span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></span><span class='comma'>,</span> <span class='symbol'>:missing_block</span><span class='comma'>,</span>
<span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="I18n.html" title="Bovem::I18n (class)">I18n</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:locale</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>root:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>bovem.application</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>path:</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_missing_app_block'>missing_app_block</span>
<span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_run'>run</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_setup_application_option'>setup_application_option</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
<span class='kw'>begin</span>
<span class='id identifier rubyid_create_application'>create_application</span><span class='lparen'>(</span><span class='id identifier rubyid_run'>run</span><span class='comma'>,</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='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>rescue</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
<span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
<span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_exit'>exit</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='comment'># Setup options for application creation.
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The options to setups.
</span> <span class='comment'># @return [Array] If to run the application, the arguments and the specified options.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_setup_application_option'>setup_application_option</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
<span class='id identifier rubyid_base_options'>base_options</span> <span class='op'>=</span> <span class='lbrace'>{</span>
<span class='label'>name:</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="I18n.html" title="Bovem::I18n (class)">I18n</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:locale</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>root:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>bovem.application</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>path:</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_default_application_name'>default_application_name</span><span class='comma'>,</span>
<span class='label'>parent:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>application:</span> <span class='kw'>nil</span>
<span class='rbrace'>}</span>
<span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_base_options'>base_options</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='rparen'>)</span>
<span class='id identifier rubyid_run'>run</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:run</span><span class='rparen'>)</span>
<span class='lbracket'>[</span><span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_run'>run</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>?</span> <span class='id identifier rubyid_run'>run</span> <span class='op'>:</span> <span class='kw'>true</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_boolean'>to_boolean</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:__args__</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rbracket'>]</span>
<span class='kw'>end</span>
<span class='comment'># Create the application.
</span> <span class='comment'>#
</span> <span class='comment'># @param run [Boolean] If to run the application.
</span> <span class='comment'># @param args [Hash] The arguments to use for running.
</span> <span class='comment'># @param options [Hash] The options of the application.
</span> <span class='comment'># @return [Application] The new application.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create_application'>create_application</span><span class='lparen'>(</span><span class='id identifier rubyid_run'>run</span><span class='comma'>,</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='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_application'>application</span> <span class='op'>=</span> <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_application'>application</span> <span class='op'>&&</span> <span class='id identifier rubyid_run'>run</span>
<span class='id identifier rubyid_application'>application</span>
<span class='kw'>end</span>
<span class='comment'># Creates a new application.
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='ivar'>@shell</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Shell.html" title="Bovem::Shell (class)">Shell</a></span></span><span class='period'>.</span><span class='id identifier rubyid_instance'><span class='object_link'><a href="Shell.html#instance-class_method" title="Bovem::Shell.instance (method)">instance</a></span></span>
<span class='ivar'>@console</span> <span class='op'>=</span> <span class='ivar'>@shell</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span>
<span class='ivar'>@skip_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='ivar'>@show_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='ivar'>@output_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='id identifier rubyid_help_option'>help_option</span>
<span class='kw'>end</span>
<span class='comment'># Reads and optionally sets the version of this application.
</span> <span class='comment'>#
</span> <span class='comment'># @param value [String|nil] The new version of this application.
</span> <span class='comment'># @return [String|nil] The version of this application.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_version'>version</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='ivar'>@version</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='ivar'>@version</span>
<span class='kw'>end</span>
<span class='comment'># Executes this application.
</span> <span class='comment'>#
</span> <span class='comment'># @param args [Array] The command line to pass to this application. Defaults to `ARGV`.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span> <span class='op'>||</span> <span class='const'>ARGV</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='comment'># Adds a help command and a help option to this application.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help_option'>help_option</span>
<span class='id identifier rubyid_command'>command</span><span class='lparen'>(</span><span class='symbol'>:help</span><span class='comma'>,</span> <span class='label'>description:</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_command_description'>help_command_description</span><span class='rparen'>)</span> <span class='kw'>do</span>
<span class='id identifier rubyid_action'>action</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_command'>command</span><span class='op'>|</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_command_help'>command_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_option'>option</span><span class='lparen'>(</span><span class='symbol'>:help</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_option_short_form'>help_option_short_form</span><span class='comma'>,</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_option_long_form'>help_option_long_form</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>help:</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_message'>help_message</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_application'>application</span><span class='comma'>,</span> <span class='id identifier rubyid__'>_</span><span class='op'>|</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span> <span class='rbrace'>}</span>
<span class='kw'>end</span>
<span class='comment'># The name of the current executable.
</span> <span class='comment'>#
</span> <span class='comment'># @return [String] The name of the current executable.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_executable_name'>executable_name</span>
<span class='gvar'>$PROGRAM_NAME</span>
<span class='kw'>end</span>
<span class='comment'># Shows a help about a command.
</span> <span class='comment'>#
</span> <span class='comment'># @param command [Command] The command to show help for.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_command_help'>command_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
<span class='id identifier rubyid_fetch_commands_for_help'>fetch_commands_for_help</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_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_arg'>arg</span><span class='op'>|</span>
<span class='comment'># Find the command across
</span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_find_command'>find_command</span><span class='lparen'>(</span><span class='id identifier rubyid_arg'>arg</span><span class='comma'>,</span> <span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='label'>args:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='kw'>break</span> <span class='kw'>unless</span> <span class='id identifier rubyid_next_command'>next_command</span>
<span class='id identifier rubyid_command'>command</span> <span class='op'>=</span> <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_commands'>commands</span><span class='lbracket'>[</span><span class='id identifier rubyid_next_command'>next_command</span><span class='lbracket'>[</span><span class='symbol'>:name</span><span class='rbracket'>]</span><span class='rbracket'>]</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span>
<span class='kw'>end</span>
<span class='comment'># Runs a command into the shell.
</span> <span class='comment'>#
</span> <span class='comment'># @param command [String] The string to run.
</span> <span class='comment'># @param message [String] A message to show before running.
</span> <span class='comment'># @param show_exit [Boolean] If show the exit status.
</span> <span class='comment'># @param fatal [Boolean] If quit in case of fatal errors.
</span> <span class='comment'># @return [Hash] An hash with `status` and `output` keys.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_show_exit'>show_exit</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='ivar'>@shell</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='op'>!</span><span class='ivar'>@skip_commands</span><span class='comma'>,</span> <span class='id identifier rubyid_show_exit'>show_exit</span><span class='comma'>,</span> <span class='ivar'>@output_commands</span><span class='comma'>,</span> <span class='ivar'>@show_commands</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_private'>private</span>
<span class='comment'># :nodoc:
</span> <span class='kw'>def</span> <span class='id identifier rubyid_fetch_commands_for_help'>fetch_commands_for_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
<span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span> <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>:</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:present?</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<span id="show_commands=-instance_method"></span>
<div class="method_details ">
<h3 class="signature " id="show_commands-instance_method">
#<strong>show_commands</strong> ⇒ <tt>Boolean</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns If to show command lines run via <span class='object_link'><a href="#run-instance_method" title="Bovem::Application#run (method)">#run</a></span>.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p>If to show command lines run via <span class='object_link'><a href="#run-instance_method" title="Bovem::Application#run (method)">#run</a></span>.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 24</span>
<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></span> <span class='op'><</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Command.html" title="Bovem::Command (class)">Command</a></span></span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:version</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:shell</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:console</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:skip_commands</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:show_commands</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:output_commands</span>
<span class='comment'># The location of the locales translation files.
</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='lparen'>(</span><span class='kw'>__FILE__</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/../../locales/</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
<span class='comment'># Initializes a new Bovem application.
</span> <span class='comment'>#
</span> <span class='comment'># In options, you can override the command line arguments with `:__args__`, and you can skip execution by specifying `run: false`.
</span> <span class='comment'>#
</span> <span class='comment'># @see Command#setup_with
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
</span> <span class='comment'># @return [Application] The created application.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>unless</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span>
<span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></span><span class='comma'>,</span> <span class='symbol'>:missing_block</span><span class='comma'>,</span>
<span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="I18n.html" title="Bovem::I18n (class)">I18n</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:locale</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>root:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>bovem.application</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>path:</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_missing_app_block'>missing_app_block</span>
<span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_run'>run</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_setup_application_option'>setup_application_option</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
<span class='kw'>begin</span>
<span class='id identifier rubyid_create_application'>create_application</span><span class='lparen'>(</span><span class='id identifier rubyid_run'>run</span><span class='comma'>,</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='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>rescue</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
<span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
<span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_exit'>exit</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='comment'># Setup options for application creation.
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The options to setups.
</span> <span class='comment'># @return [Array] If to run the application, the arguments and the specified options.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_setup_application_option'>setup_application_option</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
<span class='id identifier rubyid_base_options'>base_options</span> <span class='op'>=</span> <span class='lbrace'>{</span>
<span class='label'>name:</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="I18n.html" title="Bovem::I18n (class)">I18n</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:locale</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>root:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>bovem.application</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>path:</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_default_application_name'>default_application_name</span><span class='comma'>,</span>
<span class='label'>parent:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>application:</span> <span class='kw'>nil</span>
<span class='rbrace'>}</span>
<span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_base_options'>base_options</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='rparen'>)</span>
<span class='id identifier rubyid_run'>run</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:run</span><span class='rparen'>)</span>
<span class='lbracket'>[</span><span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_run'>run</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>?</span> <span class='id identifier rubyid_run'>run</span> <span class='op'>:</span> <span class='kw'>true</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_boolean'>to_boolean</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:__args__</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rbracket'>]</span>
<span class='kw'>end</span>
<span class='comment'># Create the application.
</span> <span class='comment'>#
</span> <span class='comment'># @param run [Boolean] If to run the application.
</span> <span class='comment'># @param args [Hash] The arguments to use for running.
</span> <span class='comment'># @param options [Hash] The options of the application.
</span> <span class='comment'># @return [Application] The new application.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create_application'>create_application</span><span class='lparen'>(</span><span class='id identifier rubyid_run'>run</span><span class='comma'>,</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='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_application'>application</span> <span class='op'>=</span> <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_application'>application</span> <span class='op'>&&</span> <span class='id identifier rubyid_run'>run</span>
<span class='id identifier rubyid_application'>application</span>
<span class='kw'>end</span>
<span class='comment'># Creates a new application.
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='ivar'>@shell</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Shell.html" title="Bovem::Shell (class)">Shell</a></span></span><span class='period'>.</span><span class='id identifier rubyid_instance'><span class='object_link'><a href="Shell.html#instance-class_method" title="Bovem::Shell.instance (method)">instance</a></span></span>
<span class='ivar'>@console</span> <span class='op'>=</span> <span class='ivar'>@shell</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span>
<span class='ivar'>@skip_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='ivar'>@show_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='ivar'>@output_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='id identifier rubyid_help_option'>help_option</span>
<span class='kw'>end</span>
<span class='comment'># Reads and optionally sets the version of this application.
</span> <span class='comment'>#
</span> <span class='comment'># @param value [String|nil] The new version of this application.
</span> <span class='comment'># @return [String|nil] The version of this application.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_version'>version</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='ivar'>@version</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='ivar'>@version</span>
<span class='kw'>end</span>
<span class='comment'># Executes this application.
</span> <span class='comment'>#
</span> <span class='comment'># @param args [Array] The command line to pass to this application. Defaults to `ARGV`.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span> <span class='op'>||</span> <span class='const'>ARGV</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='comment'># Adds a help command and a help option to this application.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help_option'>help_option</span>
<span class='id identifier rubyid_command'>command</span><span class='lparen'>(</span><span class='symbol'>:help</span><span class='comma'>,</span> <span class='label'>description:</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_command_description'>help_command_description</span><span class='rparen'>)</span> <span class='kw'>do</span>
<span class='id identifier rubyid_action'>action</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_command'>command</span><span class='op'>|</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_command_help'>command_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_option'>option</span><span class='lparen'>(</span><span class='symbol'>:help</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_option_short_form'>help_option_short_form</span><span class='comma'>,</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_option_long_form'>help_option_long_form</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>help:</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_message'>help_message</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_application'>application</span><span class='comma'>,</span> <span class='id identifier rubyid__'>_</span><span class='op'>|</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span> <span class='rbrace'>}</span>
<span class='kw'>end</span>
<span class='comment'># The name of the current executable.
</span> <span class='comment'>#
</span> <span class='comment'># @return [String] The name of the current executable.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_executable_name'>executable_name</span>
<span class='gvar'>$PROGRAM_NAME</span>
<span class='kw'>end</span>
<span class='comment'># Shows a help about a command.
</span> <span class='comment'>#
</span> <span class='comment'># @param command [Command] The command to show help for.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_command_help'>command_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
<span class='id identifier rubyid_fetch_commands_for_help'>fetch_commands_for_help</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_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_arg'>arg</span><span class='op'>|</span>
<span class='comment'># Find the command across
</span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_find_command'>find_command</span><span class='lparen'>(</span><span class='id identifier rubyid_arg'>arg</span><span class='comma'>,</span> <span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='label'>args:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='kw'>break</span> <span class='kw'>unless</span> <span class='id identifier rubyid_next_command'>next_command</span>
<span class='id identifier rubyid_command'>command</span> <span class='op'>=</span> <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_commands'>commands</span><span class='lbracket'>[</span><span class='id identifier rubyid_next_command'>next_command</span><span class='lbracket'>[</span><span class='symbol'>:name</span><span class='rbracket'>]</span><span class='rbracket'>]</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span>
<span class='kw'>end</span>
<span class='comment'># Runs a command into the shell.
</span> <span class='comment'>#
</span> <span class='comment'># @param command [String] The string to run.
</span> <span class='comment'># @param message [String] A message to show before running.
</span> <span class='comment'># @param show_exit [Boolean] If show the exit status.
</span> <span class='comment'># @param fatal [Boolean] If quit in case of fatal errors.
</span> <span class='comment'># @return [Hash] An hash with `status` and `output` keys.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_show_exit'>show_exit</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='ivar'>@shell</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='op'>!</span><span class='ivar'>@skip_commands</span><span class='comma'>,</span> <span class='id identifier rubyid_show_exit'>show_exit</span><span class='comma'>,</span> <span class='ivar'>@output_commands</span><span class='comma'>,</span> <span class='ivar'>@show_commands</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_private'>private</span>
<span class='comment'># :nodoc:
</span> <span class='kw'>def</span> <span class='id identifier rubyid_fetch_commands_for_help'>fetch_commands_for_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
<span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span> <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>:</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:present?</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<span id="skip_commands=-instance_method"></span>
<div class="method_details ">
<h3 class="signature " id="skip_commands-instance_method">
#<strong>skip_commands</strong> ⇒ <tt>Boolean</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns If to skip commands run via <span class='object_link'><a href="#run-instance_method" title="Bovem::Application#run (method)">#run</a></span>.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p>If to skip commands run via <span class='object_link'><a href="#run-instance_method" title="Bovem::Application#run (method)">#run</a></span>.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 24</span>
<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></span> <span class='op'><</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Command.html" title="Bovem::Command (class)">Command</a></span></span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:version</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:shell</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:console</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:skip_commands</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:show_commands</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:output_commands</span>
<span class='comment'># The location of the locales translation files.
</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='lparen'>(</span><span class='kw'>__FILE__</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/../../locales/</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
<span class='comment'># Initializes a new Bovem application.
</span> <span class='comment'>#
</span> <span class='comment'># In options, you can override the command line arguments with `:__args__`, and you can skip execution by specifying `run: false`.
</span> <span class='comment'>#
</span> <span class='comment'># @see Command#setup_with
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
</span> <span class='comment'># @return [Application] The created application.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>unless</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span>
<span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></span><span class='comma'>,</span> <span class='symbol'>:missing_block</span><span class='comma'>,</span>
<span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="I18n.html" title="Bovem::I18n (class)">I18n</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:locale</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>root:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>bovem.application</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>path:</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_missing_app_block'>missing_app_block</span>
<span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_run'>run</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_setup_application_option'>setup_application_option</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
<span class='kw'>begin</span>
<span class='id identifier rubyid_create_application'>create_application</span><span class='lparen'>(</span><span class='id identifier rubyid_run'>run</span><span class='comma'>,</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='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>rescue</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
<span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
<span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_exit'>exit</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='comment'># Setup options for application creation.
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The options to setups.
</span> <span class='comment'># @return [Array] If to run the application, the arguments and the specified options.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_setup_application_option'>setup_application_option</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
<span class='id identifier rubyid_base_options'>base_options</span> <span class='op'>=</span> <span class='lbrace'>{</span>
<span class='label'>name:</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="I18n.html" title="Bovem::I18n (class)">I18n</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:locale</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>root:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>bovem.application</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>path:</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_default_application_name'>default_application_name</span><span class='comma'>,</span>
<span class='label'>parent:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>application:</span> <span class='kw'>nil</span>
<span class='rbrace'>}</span>
<span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_base_options'>base_options</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='rparen'>)</span>
<span class='id identifier rubyid_run'>run</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:run</span><span class='rparen'>)</span>
<span class='lbracket'>[</span><span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_run'>run</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>?</span> <span class='id identifier rubyid_run'>run</span> <span class='op'>:</span> <span class='kw'>true</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_boolean'>to_boolean</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:__args__</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rbracket'>]</span>
<span class='kw'>end</span>
<span class='comment'># Create the application.
</span> <span class='comment'>#
</span> <span class='comment'># @param run [Boolean] If to run the application.
</span> <span class='comment'># @param args [Hash] The arguments to use for running.
</span> <span class='comment'># @param options [Hash] The options of the application.
</span> <span class='comment'># @return [Application] The new application.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create_application'>create_application</span><span class='lparen'>(</span><span class='id identifier rubyid_run'>run</span><span class='comma'>,</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='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_application'>application</span> <span class='op'>=</span> <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_application'>application</span> <span class='op'>&&</span> <span class='id identifier rubyid_run'>run</span>
<span class='id identifier rubyid_application'>application</span>
<span class='kw'>end</span>
<span class='comment'># Creates a new application.
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='ivar'>@shell</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Shell.html" title="Bovem::Shell (class)">Shell</a></span></span><span class='period'>.</span><span class='id identifier rubyid_instance'><span class='object_link'><a href="Shell.html#instance-class_method" title="Bovem::Shell.instance (method)">instance</a></span></span>
<span class='ivar'>@console</span> <span class='op'>=</span> <span class='ivar'>@shell</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span>
<span class='ivar'>@skip_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='ivar'>@show_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='ivar'>@output_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='id identifier rubyid_help_option'>help_option</span>
<span class='kw'>end</span>
<span class='comment'># Reads and optionally sets the version of this application.
</span> <span class='comment'>#
</span> <span class='comment'># @param value [String|nil] The new version of this application.
</span> <span class='comment'># @return [String|nil] The version of this application.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_version'>version</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='ivar'>@version</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='ivar'>@version</span>
<span class='kw'>end</span>
<span class='comment'># Executes this application.
</span> <span class='comment'>#
</span> <span class='comment'># @param args [Array] The command line to pass to this application. Defaults to `ARGV`.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span> <span class='op'>||</span> <span class='const'>ARGV</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='comment'># Adds a help command and a help option to this application.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help_option'>help_option</span>
<span class='id identifier rubyid_command'>command</span><span class='lparen'>(</span><span class='symbol'>:help</span><span class='comma'>,</span> <span class='label'>description:</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_command_description'>help_command_description</span><span class='rparen'>)</span> <span class='kw'>do</span>
<span class='id identifier rubyid_action'>action</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_command'>command</span><span class='op'>|</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_command_help'>command_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_option'>option</span><span class='lparen'>(</span><span class='symbol'>:help</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_option_short_form'>help_option_short_form</span><span class='comma'>,</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_option_long_form'>help_option_long_form</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>help:</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_message'>help_message</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_application'>application</span><span class='comma'>,</span> <span class='id identifier rubyid__'>_</span><span class='op'>|</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span> <span class='rbrace'>}</span>
<span class='kw'>end</span>
<span class='comment'># The name of the current executable.
</span> <span class='comment'>#
</span> <span class='comment'># @return [String] The name of the current executable.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_executable_name'>executable_name</span>
<span class='gvar'>$PROGRAM_NAME</span>
<span class='kw'>end</span>
<span class='comment'># Shows a help about a command.
</span> <span class='comment'>#
</span> <span class='comment'># @param command [Command] The command to show help for.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_command_help'>command_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
<span class='id identifier rubyid_fetch_commands_for_help'>fetch_commands_for_help</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_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_arg'>arg</span><span class='op'>|</span>
<span class='comment'># Find the command across
</span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_find_command'>find_command</span><span class='lparen'>(</span><span class='id identifier rubyid_arg'>arg</span><span class='comma'>,</span> <span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='label'>args:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='kw'>break</span> <span class='kw'>unless</span> <span class='id identifier rubyid_next_command'>next_command</span>
<span class='id identifier rubyid_command'>command</span> <span class='op'>=</span> <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_commands'>commands</span><span class='lbracket'>[</span><span class='id identifier rubyid_next_command'>next_command</span><span class='lbracket'>[</span><span class='symbol'>:name</span><span class='rbracket'>]</span><span class='rbracket'>]</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span>
<span class='kw'>end</span>
<span class='comment'># Runs a command into the shell.
</span> <span class='comment'>#
</span> <span class='comment'># @param command [String] The string to run.
</span> <span class='comment'># @param message [String] A message to show before running.
</span> <span class='comment'># @param show_exit [Boolean] If show the exit status.
</span> <span class='comment'># @param fatal [Boolean] If quit in case of fatal errors.
</span> <span class='comment'># @return [Hash] An hash with `status` and `output` keys.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_show_exit'>show_exit</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='ivar'>@shell</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='op'>!</span><span class='ivar'>@skip_commands</span><span class='comma'>,</span> <span class='id identifier rubyid_show_exit'>show_exit</span><span class='comma'>,</span> <span class='ivar'>@output_commands</span><span class='comma'>,</span> <span class='ivar'>@show_commands</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_private'>private</span>
<span class='comment'># :nodoc:
</span> <span class='kw'>def</span> <span class='id identifier rubyid_fetch_commands_for_help'>fetch_commands_for_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
<span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span> <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>:</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:present?</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<span id="version=-instance_method"></span>
<div class="method_details ">
<h3 class="signature " id="version-instance_method">
#<strong>version</strong>(value = nil) ⇒ <tt>String|nil</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Reads and optionally sets the version of this application.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>value</span>
<span class='type'>(<tt>String|nil</tt>)</span>
<em class="default">(defaults to: <tt>nil</tt>)</em>
—
<div class='inline'><p>The new version of this application.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String|nil</tt>)</span>
—
<div class='inline'><p>The version of this application.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 24</span>
<span class='kw'>class</span> <span class='const'><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></span> <span class='op'><</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Command.html" title="Bovem::Command (class)">Command</a></span></span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:version</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:shell</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:console</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:skip_commands</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:show_commands</span>
<span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:output_commands</span>
<span class='comment'># The location of the locales translation files.
</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='lparen'>(</span><span class='kw'>__FILE__</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/../../locales/</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
<span class='comment'># Initializes a new Bovem application.
</span> <span class='comment'>#
</span> <span class='comment'># In options, you can override the command line arguments with `:__args__`, and you can skip execution by specifying `run: false`.
</span> <span class='comment'>#
</span> <span class='comment'># @see Command#setup_with
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
</span> <span class='comment'># @return [Application] The created application.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>unless</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span>
<span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></span><span class='comma'>,</span> <span class='symbol'>:missing_block</span><span class='comma'>,</span>
<span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="I18n.html" title="Bovem::I18n (class)">I18n</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:locale</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>root:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>bovem.application</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>path:</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_missing_app_block'>missing_app_block</span>
<span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_run'>run</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_setup_application_option'>setup_application_option</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
<span class='kw'>begin</span>
<span class='id identifier rubyid_create_application'>create_application</span><span class='lparen'>(</span><span class='id identifier rubyid_run'>run</span><span class='comma'>,</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='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>rescue</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
<span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
<span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_exit'>exit</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='comment'># Setup options for application creation.
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The options to setups.
</span> <span class='comment'># @return [Array] If to run the application, the arguments and the specified options.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_setup_application_option'>setup_application_option</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
<span class='id identifier rubyid_base_options'>base_options</span> <span class='op'>=</span> <span class='lbrace'>{</span>
<span class='label'>name:</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="I18n.html" title="Bovem::I18n (class)">I18n</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:locale</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>root:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>bovem.application</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>path:</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_default_application_name'>default_application_name</span><span class='comma'>,</span>
<span class='label'>parent:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>application:</span> <span class='kw'>nil</span>
<span class='rbrace'>}</span>
<span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_base_options'>base_options</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='rparen'>)</span>
<span class='id identifier rubyid_run'>run</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:run</span><span class='rparen'>)</span>
<span class='lbracket'>[</span><span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_run'>run</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>?</span> <span class='id identifier rubyid_run'>run</span> <span class='op'>:</span> <span class='kw'>true</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_boolean'>to_boolean</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:__args__</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rbracket'>]</span>
<span class='kw'>end</span>
<span class='comment'># Create the application.
</span> <span class='comment'>#
</span> <span class='comment'># @param run [Boolean] If to run the application.
</span> <span class='comment'># @param args [Hash] The arguments to use for running.
</span> <span class='comment'># @param options [Hash] The options of the application.
</span> <span class='comment'># @return [Application] The new application.
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create_application'>create_application</span><span class='lparen'>(</span><span class='id identifier rubyid_run'>run</span><span class='comma'>,</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='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_application'>application</span> <span class='op'>=</span> <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_application'>application</span> <span class='op'>&&</span> <span class='id identifier rubyid_run'>run</span>
<span class='id identifier rubyid_application'>application</span>
<span class='kw'>end</span>
<span class='comment'># Creates a new application.
</span> <span class='comment'>#
</span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='ivar'>@shell</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Shell.html" title="Bovem::Shell (class)">Shell</a></span></span><span class='period'>.</span><span class='id identifier rubyid_instance'><span class='object_link'><a href="Shell.html#instance-class_method" title="Bovem::Shell.instance (method)">instance</a></span></span>
<span class='ivar'>@console</span> <span class='op'>=</span> <span class='ivar'>@shell</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span>
<span class='ivar'>@skip_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='ivar'>@show_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='ivar'>@output_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='id identifier rubyid_help_option'>help_option</span>
<span class='kw'>end</span>
<span class='comment'># Reads and optionally sets the version of this application.
</span> <span class='comment'>#
</span> <span class='comment'># @param value [String|nil] The new version of this application.
</span> <span class='comment'># @return [String|nil] The version of this application.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_version'>version</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='ivar'>@version</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='ivar'>@version</span>
<span class='kw'>end</span>
<span class='comment'># Executes this application.
</span> <span class='comment'>#
</span> <span class='comment'># @param args [Array] The command line to pass to this application. Defaults to `ARGV`.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span> <span class='op'>||</span> <span class='const'>ARGV</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='comment'># Adds a help command and a help option to this application.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_help_option'>help_option</span>
<span class='id identifier rubyid_command'>command</span><span class='lparen'>(</span><span class='symbol'>:help</span><span class='comma'>,</span> <span class='label'>description:</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_command_description'>help_command_description</span><span class='rparen'>)</span> <span class='kw'>do</span>
<span class='id identifier rubyid_action'>action</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_command'>command</span><span class='op'>|</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_command_help'>command_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_option'>option</span><span class='lparen'>(</span><span class='symbol'>:help</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_option_short_form'>help_option_short_form</span><span class='comma'>,</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_option_long_form'>help_option_long_form</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>help:</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_message'>help_message</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_application'>application</span><span class='comma'>,</span> <span class='id identifier rubyid__'>_</span><span class='op'>|</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span> <span class='rbrace'>}</span>
<span class='kw'>end</span>
<span class='comment'># The name of the current executable.
</span> <span class='comment'>#
</span> <span class='comment'># @return [String] The name of the current executable.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_executable_name'>executable_name</span>
<span class='gvar'>$PROGRAM_NAME</span>
<span class='kw'>end</span>
<span class='comment'># Shows a help about a command.
</span> <span class='comment'>#
</span> <span class='comment'># @param command [Command] The command to show help for.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_command_help'>command_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
<span class='id identifier rubyid_fetch_commands_for_help'>fetch_commands_for_help</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_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_arg'>arg</span><span class='op'>|</span>
<span class='comment'># Find the command across
</span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_find_command'>find_command</span><span class='lparen'>(</span><span class='id identifier rubyid_arg'>arg</span><span class='comma'>,</span> <span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='label'>args:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='kw'>break</span> <span class='kw'>unless</span> <span class='id identifier rubyid_next_command'>next_command</span>
<span class='id identifier rubyid_command'>command</span> <span class='op'>=</span> <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_commands'>commands</span><span class='lbracket'>[</span><span class='id identifier rubyid_next_command'>next_command</span><span class='lbracket'>[</span><span class='symbol'>:name</span><span class='rbracket'>]</span><span class='rbracket'>]</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span>
<span class='kw'>end</span>
<span class='comment'># Runs a command into the shell.
</span> <span class='comment'>#
</span> <span class='comment'># @param command [String] The string to run.
</span> <span class='comment'># @param message [String] A message to show before running.
</span> <span class='comment'># @param show_exit [Boolean] If show the exit status.
</span> <span class='comment'># @param fatal [Boolean] If quit in case of fatal errors.
</span> <span class='comment'># @return [Hash] An hash with `status` and `output` keys.
</span> <span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_show_exit'>show_exit</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='ivar'>@shell</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='op'>!</span><span class='ivar'>@skip_commands</span><span class='comma'>,</span> <span class='id identifier rubyid_show_exit'>show_exit</span><span class='comma'>,</span> <span class='ivar'>@output_commands</span><span class='comma'>,</span> <span class='ivar'>@show_commands</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_private'>private</span>
<span class='comment'># :nodoc:
</span> <span class='kw'>def</span> <span class='id identifier rubyid_fetch_commands_for_help'>fetch_commands_for_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
<span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span> <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>:</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:present?</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="class_method_details" class="method_details_list">
<h2>Class Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="create-class_method">
.<strong>create</strong>(options = {}, &block) ⇒ <tt><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Initializes a new Bovem application.</p>
<p>In options, you can override the command line arguments with <code>:__args__</code>, and you can skip execution by specifying <code>run: false</code>.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>options</span>
<span class='type'>(<tt>Hash</tt>)</span>
<em class="default">(defaults to: <tt>{}</tt>)</em>
—
<div class='inline'><p>The settings to initialize the application with.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></tt>)</span>
—
<div class='inline'><p>The created application.</p>
</div>
</li>
</ul>
<p class="tag_title">See Also:</p>
<ul class="see">
<li><span class='object_link'><a href="Command.html#setup_with-instance_method" title="Bovem::Command#setup_with (method)">Command#setup_with</a></span></li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 43</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>unless</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors.html" title="Bovem::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Error</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Errors/Error.html#initialize-instance_method" title="Bovem::Errors::Error#initialize (method)">new</a></span></span><span class='lparen'>(</span>
<span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></span><span class='comma'>,</span> <span class='symbol'>:missing_block</span><span class='comma'>,</span>
<span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="I18n.html" title="Bovem::I18n (class)">I18n</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:locale</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>root:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>bovem.application</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>path:</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_missing_app_block'>missing_app_block</span>
<span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_run'>run</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_setup_application_option'>setup_application_option</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
<span class='kw'>begin</span>
<span class='id identifier rubyid_create_application'>create_application</span><span class='lparen'>(</span><span class='id identifier rubyid_run'>run</span><span class='comma'>,</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='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>rescue</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
<span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
<span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_exit'>exit</span><span class='lparen'>(</span><span class='int'>1</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="create_application-class_method">
.<strong>create_application</strong>(run, args, options, &block) ⇒ <tt><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Create the application.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>run</span>
<span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p>If to run the application.</p>
</div>
</li>
<li>
<span class='name'>args</span>
<span class='type'>(<tt>Hash</tt>)</span>
—
<div class='inline'><p>The arguments to use for running.</p>
</div>
</li>
<li>
<span class='name'>options</span>
<span class='type'>(<tt>Hash</tt>)</span>
—
<div class='inline'><p>The options of the application.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></tt>)</span>
—
<div class='inline'><p>The new application.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
81
82
83
84
85</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 81</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create_application'>create_application</span><span class='lparen'>(</span><span class='id identifier rubyid_run'>run</span><span class='comma'>,</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='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_application'>application</span> <span class='op'>=</span> <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_application'>application</span> <span class='op'>&&</span> <span class='id identifier rubyid_run'>run</span>
<span class='id identifier rubyid_application'>application</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="setup_application_option-class_method">
.<strong>setup_application_option</strong>(options) ⇒ <tt>Array</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Setup options for application creation.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>options</span>
<span class='type'>(<tt>Hash</tt>)</span>
—
<div class='inline'><p>The options to setups.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Array</tt>)</span>
—
<div class='inline'><p>If to run the application, the arguments and the specified options.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
65
66
67
68
69
70
71
72
73</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 65</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_setup_application_option'>setup_application_option</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
<span class='id identifier rubyid_base_options'>base_options</span> <span class='op'>=</span> <span class='lbrace'>{</span>
<span class='label'>name:</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="I18n.html" title="Bovem::I18n (class)">I18n</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:locale</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>root:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>bovem.application</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>path:</span> <span class='const'><span class='object_link'><a href="#LOCALE_ROOT-constant" title="Bovem::Application::LOCALE_ROOT (constant)">LOCALE_ROOT</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_default_application_name'>default_application_name</span><span class='comma'>,</span>
<span class='label'>parent:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>application:</span> <span class='kw'>nil</span>
<span class='rbrace'>}</span>
<span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_base_options'>base_options</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_ensure_hash'>ensure_hash</span><span class='rparen'>)</span>
<span class='id identifier rubyid_run'>run</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:run</span><span class='rparen'>)</span>
<span class='lbracket'>[</span><span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_run'>run</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>?</span> <span class='id identifier rubyid_run'>run</span> <span class='op'>:</span> <span class='kw'>true</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_boolean'>to_boolean</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:__args__</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rbracket'>]</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="command_help-instance_method">
#<strong>command_help</strong>(command) ⇒ <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Shows a help about a command.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>command</span>
<span class='type'>(<tt><span class='object_link'><a href="Command.html" title="Bovem::Command (class)">Command</a></span></tt>)</span>
—
<div class='inline'><p>The command to show help for.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
137
138
139
140
141
142
143
144
145
146</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 137</span>
<span class='kw'>def</span> <span class='id identifier rubyid_command_help'>command_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
<span class='id identifier rubyid_fetch_commands_for_help'>fetch_commands_for_help</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_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_arg'>arg</span><span class='op'>|</span>
<span class='comment'># Find the command across
</span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Parser.html" title="Bovem::Parser (class)">Parser</a></span></span><span class='period'>.</span><span class='id identifier rubyid_find_command'>find_command</span><span class='lparen'>(</span><span class='id identifier rubyid_arg'>arg</span><span class='comma'>,</span> <span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='label'>args:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='kw'>break</span> <span class='kw'>unless</span> <span class='id identifier rubyid_next_command'>next_command</span>
<span class='id identifier rubyid_command'>command</span> <span class='op'>=</span> <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_commands'>commands</span><span class='lbracket'>[</span><span class='id identifier rubyid_next_command'>next_command</span><span class='lbracket'>[</span><span class='symbol'>:name</span><span class='rbracket'>]</span><span class='rbracket'>]</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="executable_name-instance_method">
#<strong>executable_name</strong> ⇒ <tt>String</tt>
</h3><div class="docstring">
<div class="discussion">
<p>The name of the current executable.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>The name of the current executable.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
130
131
132</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 130</span>
<span class='kw'>def</span> <span class='id identifier rubyid_executable_name'>executable_name</span>
<span class='gvar'>$PROGRAM_NAME</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="execute-instance_method">
#<strong>execute</strong>(args = nil) ⇒ <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Executes this application.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>args</span>
<span class='type'>(<tt>Array</tt>)</span>
<em class="default">(defaults to: <tt>nil</tt>)</em>
—
<div class='inline'><p>The command line to pass to this application. Defaults to <code>ARGV</code>.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
114
115
116</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 114</span>
<span class='kw'>def</span> <span class='id identifier rubyid_execute'>execute</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span> <span class='op'>||</span> <span class='const'>ARGV</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="help_option-instance_method">
#<strong>help_option</strong> ⇒ <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Adds a help command and a help option to this application.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
119
120
121
122
123
124
125</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 119</span>
<span class='kw'>def</span> <span class='id identifier rubyid_help_option'>help_option</span>
<span class='id identifier rubyid_command'>command</span><span class='lparen'>(</span><span class='symbol'>:help</span><span class='comma'>,</span> <span class='label'>description:</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_command_description'>help_command_description</span><span class='rparen'>)</span> <span class='kw'>do</span>
<span class='id identifier rubyid_action'>action</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_command'>command</span><span class='op'>|</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_command_help'>command_help</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_option'>option</span><span class='lparen'>(</span><span class='symbol'>:help</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_option_short_form'>help_option_short_form</span><span class='comma'>,</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_option_long_form'>help_option_long_form</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>help:</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_help_message'>help_message</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_application'>application</span><span class='comma'>,</span> <span class='id identifier rubyid__'>_</span><span class='op'>|</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="run-instance_method">
#<strong>run</strong>(command, message = nil, show_exit = true, fatal = true) ⇒ <tt>Hash</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Runs a command into the shell.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>command</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>The string to run.</p>
</div>
</li>
<li>
<span class='name'>message</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>nil</tt>)</em>
—
<div class='inline'><p>A message to show before running.</p>
</div>
</li>
<li>
<span class='name'>show_exit</span>
<span class='type'>(<tt>Boolean</tt>)</span>
<em class="default">(defaults to: <tt>true</tt>)</em>
—
<div class='inline'><p>If show the exit status.</p>
</div>
</li>
<li>
<span class='name'>fatal</span>
<span class='type'>(<tt>Boolean</tt>)</span>
<em class="default">(defaults to: <tt>true</tt>)</em>
—
<div class='inline'><p>If quit in case of fatal errors.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Hash</tt>)</span>
—
<div class='inline'><p>An hash with <code>status</code> and <code>output</code> keys.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
155
156
157</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 155</span>
<span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_show_exit'>show_exit</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='ivar'>@shell</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='op'>!</span><span class='ivar'>@skip_commands</span><span class='comma'>,</span> <span class='id identifier rubyid_show_exit'>show_exit</span><span class='comma'>,</span> <span class='ivar'>@output_commands</span><span class='comma'>,</span> <span class='ivar'>@show_commands</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Thu Jan 12 16:11:01 2017 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.7 (ruby-2.3.0).
</div>
</div>
</body>
</html>