bovem 2.4.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Gemfile +1 -1
  4. data/README.md +98 -2
  5. data/bovem.gemspec +3 -3
  6. data/doc/Bovem.html +25 -6
  7. data/doc/Bovem/Application.html +3057 -0
  8. data/doc/Bovem/Command.html +7031 -0
  9. data/doc/Bovem/CommandMethods.html +125 -0
  10. data/doc/Bovem/CommandMethods/Children.html +1285 -0
  11. data/doc/Bovem/CommandMethods/Help.html +209 -0
  12. data/doc/Bovem/Configuration.html +3 -3
  13. data/doc/Bovem/Console.html +8 -8
  14. data/doc/Bovem/ConsoleMethods.html +3 -3
  15. data/doc/Bovem/ConsoleMethods/Interactions.html +3 -3
  16. data/doc/Bovem/ConsoleMethods/Interactions/ClassMethods.html +3 -3
  17. data/doc/Bovem/ConsoleMethods/Logging.html +4 -4
  18. data/doc/Bovem/ConsoleMethods/Logging/ClassMethods.html +3 -3
  19. data/doc/Bovem/ConsoleMethods/Output.html +3 -3
  20. data/doc/Bovem/ConsoleMethods/StyleHandling.html +4 -4
  21. data/doc/Bovem/ConsoleMethods/StyleHandling/ClassMethods.html +8 -8
  22. data/doc/Bovem/Errors.html +4 -4
  23. data/doc/Bovem/Errors/Error.html +631 -0
  24. data/doc/Bovem/Errors/InvalidConfiguration.html +3 -3
  25. data/doc/Bovem/Errors/InvalidLogger.html +3 -3
  26. data/doc/Bovem/Localizer.html +376 -0
  27. data/doc/Bovem/Logger.html +64 -160
  28. data/doc/Bovem/Option.html +7009 -0
  29. data/doc/Bovem/Parser.html +276 -0
  30. data/doc/Bovem/ParserMethods.html +125 -0
  31. data/doc/Bovem/ParserMethods/General.html +134 -0
  32. data/doc/Bovem/ParserMethods/General/ClassMethods.html +574 -0
  33. data/doc/Bovem/Shell.html +8 -8
  34. data/doc/Bovem/ShellMethods.html +3 -3
  35. data/doc/Bovem/ShellMethods/Directories.html +3 -3
  36. data/doc/Bovem/ShellMethods/Execute.html +3 -3
  37. data/doc/Bovem/ShellMethods/General.html +3 -3
  38. data/doc/Bovem/ShellMethods/Read.html +3 -3
  39. data/doc/Bovem/ShellMethods/Write.html +3 -3
  40. data/doc/Bovem/Version.html +6 -6
  41. data/doc/_index.html +119 -11
  42. data/doc/class_list.html +1 -1
  43. data/doc/file.README.html +98 -5
  44. data/doc/frames.html +1 -1
  45. data/doc/index.html +98 -5
  46. data/doc/method_list.html +476 -26
  47. data/doc/top-level-namespace.html +3 -3
  48. data/lib/bovem.rb +8 -1
  49. data/lib/bovem/application.rb +158 -0
  50. data/lib/bovem/command.rb +529 -0
  51. data/lib/bovem/console.rb +8 -8
  52. data/lib/bovem/errors.rb +27 -0
  53. data/lib/bovem/localizer.rb +27 -0
  54. data/lib/bovem/logger.rb +2 -8
  55. data/lib/bovem/option.rb +250 -0
  56. data/lib/bovem/parser.rb +317 -0
  57. data/lib/bovem/shell.rb +2 -2
  58. data/lib/bovem/version.rb +3 -3
  59. data/locales/en.yml +33 -0
  60. data/locales/it.yml +33 -0
  61. data/spec/bovem/application_spec.rb +170 -0
  62. data/spec/bovem/command_spec.rb +526 -0
  63. data/spec/bovem/configuration_spec.rb +4 -4
  64. data/spec/bovem/console_spec.rb +22 -22
  65. data/spec/bovem/errors_spec.rb +18 -0
  66. data/spec/bovem/logger_spec.rb +22 -12
  67. data/spec/bovem/option_spec.rb +307 -0
  68. data/spec/bovem/parser_spec.rb +126 -0
  69. data/spec/bovem/shell_spec.rb +4 -4
  70. metadata +32 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d30958ab82686cc8d470263f67d7574cf93b0200
4
- data.tar.gz: c056ae97e7bf468bef4416e472425f729e83b68f
3
+ metadata.gz: 9da3864e3059ee61e788984c99735abde158e810
4
+ data.tar.gz: f55f4b13065d1142e80841d2a1ef1089db62cfd7
5
5
  SHA512:
6
- metadata.gz: 580c85e9b87a5a9b736d30a3a2e9bac156ef76382375cc025f7213383dd7cb5eb4f0c6f870077201eab4533378a1a583d367d2ce8a46b733f034def412662a75
7
- data.tar.gz: 86de02c6e1f81103176fcc3e9b32a4efc8eaf332160bff6e9252045c8996bdfa4fdcd566bc1303561d31d72062053db7248288ffcca35d2e027c3210623bccd6
6
+ metadata.gz: 1fe46dc48a76bfa71df3505d39b0c2a8938743c172d7b3c26e743061dcd378ddf4da6d26699e89adf90686c85316062b4d258949221fc426387b7deaebafe9e2
7
+ data.tar.gz: c2ca4b6936d4fccb59914ba3247079cf8585d39406d1133a5e3aa51b3cbc0ca916712567f01f98b444fd7598b4eb957d8d94b58a09e2f61fd7eeeadbb675fef2
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  Gemfile.lock
2
- tester.rb
2
+ utils_tester.rb
3
+ cli_tester.rb
3
4
  coverage/
4
5
  pkg/
5
6
  .idea/
data/Gemfile CHANGED
@@ -16,6 +16,6 @@ gem "rake", "~> 10.1.0"
16
16
  gem "simplecov", ">= 0.7.1"
17
17
  gem "coveralls", ">= 0.6.7", require: false
18
18
  gem "pry", ">= 0"
19
- gem "yard", ">= 0.8.6"
19
+ gem "yard", ">= 0.8.7"
20
20
  gem "kramdown", ">= 1.1.0"
21
21
  gem "github-markup", ">= 0.7.5"
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  [![Code Climate](https://codeclimate.com/github/ShogunPanda/bovem.png)](https://codeclimate.com/github/ShogunPanda/bovem)
7
7
  [![Coverage Status](https://coveralls.io/repos/ShogunPanda/bovem/badge.png)](https://coveralls.io/r/ShogunPanda/bovem)
8
8
 
9
- A collection of utilities for developers.
9
+ A command line manager and a collection of utilities for developers.
10
10
 
11
11
  http://sw.cow.tc/bovem
12
12
 
@@ -14,10 +14,106 @@ http://rdoc.info/gems/bovem
14
14
 
15
15
  ## Description
16
16
 
17
- Bovem is a small set of utilities for Ruby developers.
17
+ Bovem is a command line manager and small set of utilities for Ruby developers.
18
18
 
19
19
  See the documentation for more informations.
20
20
 
21
+ ## Basic usage.
22
+
23
+ As ever, talking by example is always better.
24
+ This application:
25
+
26
+ ```ruby
27
+ require "bovem"
28
+
29
+ Bovem::Application.create(name: "Bovem Usage Test", version: "1.0.0", description: "An example modelled like a TODO application", banner: "Do you like Bovem?") do
30
+ option(:storage, ["f", "file"], {type: String, help: "The file where store TODOs to.", meta: "FILE"})
31
+
32
+ command :list do
33
+ description "List all TODOs."
34
+ action do |command|
35
+ # You should implement this.
36
+ end
37
+ end
38
+
39
+ command :manage, {description: "Manage existing TODO."} do
40
+ option(:verbose, [], {help: "Be verbose."})
41
+
42
+ action do |command|
43
+ puts "Please use \"add\" or \"remove\" subcommands."
44
+ end
45
+
46
+ command :add, {description: "Add a TODO."} do
47
+ action do |command|
48
+ # You should implement this.
49
+ end
50
+ end
51
+
52
+ command :remove, {description: "Removes a TODO."} do
53
+ action do |command|
54
+ # You should implement this.
55
+ end
56
+ end
57
+ end
58
+ end
59
+ ```
60
+
61
+ Will create a complete (at least at the interface model) TODO application which support commands `list` and `manage`.
62
+
63
+ The `manage` command supports subcommands `add` and `remove`. You can invoke it via syntax `manage add` or `manage:add`. **If there is no conflict, just `m:r` is sufficient!**
64
+
65
+ To provide (sub)commands, both hash-style or block-style method style are supported (except for the `action` option), as you can see in the example.
66
+
67
+ You can use the `--help` switch or the `help command` syntax to navigate through commands details.
68
+
69
+ After setting up the skeleton, you will just need to write the action bodies and you're done. **Happy coding!**
70
+
71
+ ### Wrapping up the example
72
+ Here's the help screen of the application above for the global application and for the `manage` command.
73
+
74
+ #### General help
75
+
76
+ ```
77
+ $ ./test -h
78
+ [NAME]
79
+ Bovem Usage Test 1.0.0 - An example modelled like a TODO application
80
+
81
+ [SYNOPSIS]
82
+ test [options] [command [subcommand ...]][command-options] [arguments]
83
+
84
+ [DESCRIPTION]
85
+ Do you like Bovem?
86
+
87
+ [GLOBAL OPTIONS]
88
+ -f FILE, --file FILE - The file where store TODOs to.
89
+ -h, --help - Shows this message.
90
+
91
+ [COMMANDS]
92
+ help - Shows a help about a command.
93
+ list - List all TODOs.
94
+ manage - Manage existing TODO.
95
+ ```
96
+
97
+ #### The `manage` command help
98
+
99
+ ```
100
+ $ ./test help manage
101
+ [SYNOPSIS]
102
+ test [options] manage [subcommand ...]] [command-options] [arguments]
103
+
104
+ [OPTIONS]
105
+ -v, --verbose - Be verbose.
106
+
107
+ [SUBCOMMANDS]
108
+ add - Add a TODO.
109
+ remove - Removes a TODO.
110
+ ```
111
+
112
+
113
+ ## Advanced usage
114
+
115
+ See documentation for more information.
116
+
21
117
  ## Contributing to bovem
22
118
 
23
119
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
data/bovem.gemspec CHANGED
@@ -12,8 +12,8 @@ Gem::Specification.new do |gem|
12
12
  gem.authors = ["Shogun"]
13
13
  gem.email = ["shogun_panda@me.com"]
14
14
  gem.homepage = "http://sw.cow.tc/bovem"
15
- gem.summary = %q{A collection of utilities for developers.}
16
- gem.description = %q{A collection of utilities for developers.}
15
+ gem.summary = %q{A command line manager and a collection of utilities for developers.}
16
+ gem.description = %q{A command line manager and a collection of utilities for developers.}
17
17
 
18
18
  gem.rubyforge_project = "bovem"
19
19
  gem.files = `git ls-files`.split("\n")
@@ -23,6 +23,6 @@ Gem::Specification.new do |gem|
23
23
 
24
24
  gem.required_ruby_version = ">= 1.9.3"
25
25
 
26
- gem.add_dependency("lazier", "~> 3.3.1")
26
+ gem.add_dependency("lazier", "~> 3.3.5")
27
27
  gem.add_dependency("open4", "~> 1.3.0")
28
28
  end
data/doc/Bovem.html CHANGED
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Module: Bovem
8
8
 
9
- &mdash; Documentation by YARD 0.8.6.2
9
+ &mdash; Documentation by YARD 0.8.7
10
10
 
11
11
  </title>
12
12
 
@@ -80,7 +80,7 @@
80
80
 
81
81
  <dt class="r1 last">Defined in:</dt>
82
82
  <dd class="r1 last">lib/bovem/shell.rb<span class="defines">,<br />
83
- lib/bovem/errors.rb,<br /> lib/bovem/logger.rb,<br /> lib/bovem/console.rb,<br /> lib/bovem/version.rb,<br /> lib/bovem/configuration.rb</span>
83
+ lib/bovem/parser.rb,<br /> lib/bovem/option.rb,<br /> lib/bovem/errors.rb,<br /> lib/bovem/logger.rb,<br /> lib/bovem/command.rb,<br /> lib/bovem/console.rb,<br /> lib/bovem/version.rb,<br /> lib/bovem/localizer.rb,<br /> lib/bovem/application.rb,<br /> lib/bovem/configuration.rb</span>
84
84
  </dd>
85
85
 
86
86
  </dl>
@@ -101,11 +101,11 @@ Licensed under the MIT license, which can be found at http://www.opensource.org/
101
101
  <p class="children">
102
102
 
103
103
 
104
- <strong class="modules">Modules:</strong> <span class='object_link'><a href="Bovem/ConsoleMethods.html" title="Bovem::ConsoleMethods (module)">ConsoleMethods</a></span>, <span class='object_link'><a href="Bovem/Errors.html" title="Bovem::Errors (module)">Errors</a></span>, <span class='object_link'><a href="Bovem/ShellMethods.html" title="Bovem::ShellMethods (module)">ShellMethods</a></span>, <span class='object_link'><a href="Bovem/Version.html" title="Bovem::Version (module)">Version</a></span>
104
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Bovem/CommandMethods.html" title="Bovem::CommandMethods (module)">CommandMethods</a></span>, <span class='object_link'><a href="Bovem/ConsoleMethods.html" title="Bovem::ConsoleMethods (module)">ConsoleMethods</a></span>, <span class='object_link'><a href="Bovem/Errors.html" title="Bovem::Errors (module)">Errors</a></span>, <span class='object_link'><a href="Bovem/ParserMethods.html" title="Bovem::ParserMethods (module)">ParserMethods</a></span>, <span class='object_link'><a href="Bovem/ShellMethods.html" title="Bovem::ShellMethods (module)">ShellMethods</a></span>, <span class='object_link'><a href="Bovem/Version.html" title="Bovem::Version (module)">Version</a></span>
105
105
 
106
106
 
107
107
 
108
- <strong class="classes">Classes:</strong> <span class='object_link'><a href="Bovem/Configuration.html" title="Bovem::Configuration (class)">Configuration</a></span>, <span class='object_link'><a href="Bovem/Console.html" title="Bovem::Console (class)">Console</a></span>, <span class='object_link'><a href="Bovem/Logger.html" title="Bovem::Logger (class)">Logger</a></span>, <span class='object_link'><a href="Bovem/Shell.html" title="Bovem::Shell (class)">Shell</a></span>
108
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Bovem/Application.html" title="Bovem::Application (class)">Application</a></span>, <span class='object_link'><a href="Bovem/Command.html" title="Bovem::Command (class)">Command</a></span>, <span class='object_link'><a href="Bovem/Configuration.html" title="Bovem::Configuration (class)">Configuration</a></span>, <span class='object_link'><a href="Bovem/Console.html" title="Bovem::Console (class)">Console</a></span>, <span class='object_link'><a href="Bovem/Localizer.html" title="Bovem::Localizer (class)">Localizer</a></span>, <span class='object_link'><a href="Bovem/Logger.html" title="Bovem::Logger (class)">Logger</a></span>, <span class='object_link'><a href="Bovem/Option.html" title="Bovem::Option (class)">Option</a></span>, <span class='object_link'><a href="Bovem/Parser.html" title="Bovem::Parser (class)">Parser</a></span>, <span class='object_link'><a href="Bovem/Shell.html" title="Bovem::Shell (class)">Shell</a></span>
109
109
 
110
110
 
111
111
  </p>
@@ -114,6 +114,25 @@ Licensed under the MIT license, which can be found at http://www.opensource.org/
114
114
 
115
115
  <dl class="constants">
116
116
 
117
+ <dt id="OPTION_TYPES-constant" class="">OPTION_TYPES =
118
+ <div class="docstring">
119
+ <div class="discussion">
120
+ <p>List of valid option types.</p>
121
+
122
+ <p>Values are the default values for that type.</p>
123
+
124
+ <p>For any unknown type, the default value is <code>false</code>, it means that any unknown type is managed as a Boolean value with no argument.</p>
125
+
126
+
127
+ </div>
128
+ </div>
129
+ <div class="tags">
130
+
131
+
132
+ </div>
133
+ </dt>
134
+ <dd><pre class="code"><span class='lbrace'>{</span><span class='const'>String</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='const'>Integer</span> <span class='op'>=&gt;</span> <span class='int'>0</span><span class='comma'>,</span> <span class='const'>Float</span> <span class='op'>=&gt;</span> <span class='float'>0.0</span><span class='comma'>,</span> <span class='const'>Array</span> <span class='op'>=&gt;</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rbrace'>}</span></pre></dd>
135
+
117
136
  <dt id="TERM_COLORS-constant" class="">TERM_COLORS =
118
137
  <div class="docstring">
119
138
  <div class="discussion">
@@ -158,9 +177,9 @@ Licensed under the MIT license, which can be found at http://www.opensource.org/
158
177
  </div>
159
178
 
160
179
  <div id="footer">
161
- Generated on Sat Aug 3 12:38:42 2013 by
180
+ Generated on Sat Aug 3 13:50:14 2013 by
162
181
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
163
- 0.8.6.2 (ruby-2.0.0).
182
+ 0.8.7 (ruby-2.0.0).
164
183
  </div>
165
184
 
166
185
  </body>
@@ -0,0 +1,3057 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: Bovem::Application
8
+
9
+ &mdash; Documentation by YARD 0.8.7
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../';
20
+ framesUrl = "../frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../_index.html">Index (A)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../Bovem.html" title="Bovem (module)">Bovem</a></span></span>
36
+ &raquo;
37
+ <span class="title">Application</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Class: Bovem::Application
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+ <dt class="r1">Inherits:</dt>
75
+ <dd class="r1">
76
+ <span class="inheritName"><span class='object_link'><a href="Command.html" title="Bovem::Command (class)">Command</a></span></span>
77
+
78
+ <ul class="fullTree">
79
+ <li>Object</li>
80
+
81
+ <li class="next"><span class='object_link'><a href="Command.html" title="Bovem::Command (class)">Command</a></span></li>
82
+
83
+ <li class="next">Bovem::Application</li>
84
+
85
+ </ul>
86
+ <a href="#" class="inheritanceTree">show all</a>
87
+
88
+ </dd>
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+ <dt class="r2 last">Defined in:</dt>
99
+ <dd class="r2 last">lib/bovem/application.rb</dd>
100
+
101
+ </dl>
102
+ <div class="clear"></div>
103
+
104
+ <h2>Overview</h2><div class="docstring">
105
+ <div class="discussion">
106
+ <p>This is the main class for a Bovem application.</p>
107
+
108
+ <p>Basically is the same of a command, but it adds support for application version.</p>
109
+
110
+
111
+ </div>
112
+ </div>
113
+ <div class="tags">
114
+
115
+
116
+ </div>
117
+
118
+
119
+
120
+ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
121
+ <ul class="summary">
122
+
123
+ <li class="public ">
124
+ <span class="summary_signature">
125
+
126
+ <a href="#console-instance_method" title="#console (instance method)">- (Bovem::Console) <strong>console</strong> </a>
127
+
128
+
129
+
130
+ </span>
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+ <span class="summary_desc"><div class='inline'><p>A console helper.</p>
144
+ </div></span>
145
+
146
+ </li>
147
+
148
+
149
+ <li class="public ">
150
+ <span class="summary_signature">
151
+
152
+ <a href="#output_commands-instance_method" title="#output_commands (instance method)">- (Boolean) <strong>output_commands</strong> </a>
153
+
154
+
155
+
156
+ </span>
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+ <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>
170
+ </div></span>
171
+
172
+ </li>
173
+
174
+
175
+ <li class="public ">
176
+ <span class="summary_signature">
177
+
178
+ <a href="#shell-instance_method" title="#shell (instance method)">- (Bovem::Shell) <strong>shell</strong> </a>
179
+
180
+
181
+
182
+ </span>
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+ <span class="summary_desc"><div class='inline'><p>A shell helper.</p>
196
+ </div></span>
197
+
198
+ </li>
199
+
200
+
201
+ <li class="public ">
202
+ <span class="summary_signature">
203
+
204
+ <a href="#show_commands-instance_method" title="#show_commands (instance method)">- (Boolean) <strong>show_commands</strong> </a>
205
+
206
+
207
+
208
+ </span>
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+ <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>
222
+ </div></span>
223
+
224
+ </li>
225
+
226
+
227
+ <li class="public ">
228
+ <span class="summary_signature">
229
+
230
+ <a href="#skip_commands-instance_method" title="#skip_commands (instance method)">- (Boolean) <strong>skip_commands</strong> </a>
231
+
232
+
233
+
234
+ </span>
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+ <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>
248
+ </div></span>
249
+
250
+ </li>
251
+
252
+
253
+ <li class="public ">
254
+ <span class="summary_signature">
255
+
256
+ <a href="#version-instance_method" title="#version (instance method)">- (String|nil) <strong>version</strong>(value = nil) </a>
257
+
258
+
259
+
260
+ </span>
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+ <span class="summary_desc"><div class='inline'><p>Reads and optionally sets the version of this application.</p>
274
+ </div></span>
275
+
276
+ </li>
277
+
278
+
279
+ </ul>
280
+
281
+
282
+
283
+
284
+
285
+ <h3 class="inherited">Attributes inherited from <span class='object_link'><a href="Command.html" title="Bovem::Command (class)">Command</a></span></h3>
286
+ <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#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>
287
+
288
+
289
+
290
+ <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>
291
+ <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>
292
+
293
+
294
+
295
+ <h2>
296
+ Class Method Summary
297
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
298
+ </h2>
299
+
300
+ <ul class="summary">
301
+
302
+ <li class="public ">
303
+ <span class="summary_signature">
304
+
305
+ <a href="#create-class_method" title="create (class method)">+ (Application) <strong>create</strong>(options = {}, &amp;block) </a>
306
+
307
+
308
+
309
+ </span>
310
+
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+ <span class="summary_desc"><div class='inline'><p>Initializes a new Bovem application.</p>
320
+ </div></span>
321
+
322
+ </li>
323
+
324
+
325
+ </ul>
326
+
327
+ <h2>
328
+ Instance Method Summary
329
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
330
+ </h2>
331
+
332
+ <ul class="summary">
333
+
334
+ <li class="public ">
335
+ <span class="summary_signature">
336
+
337
+ <a href="#command_help-instance_method" title="#command_help (instance method)">- (Object) <strong>command_help</strong>(command) </a>
338
+
339
+
340
+
341
+ </span>
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+ <span class="summary_desc"><div class='inline'><p>Shows a help about a command.</p>
352
+ </div></span>
353
+
354
+ </li>
355
+
356
+
357
+ <li class="public ">
358
+ <span class="summary_signature">
359
+
360
+ <a href="#executable_name-instance_method" title="#executable_name (instance method)">- (String) <strong>executable_name</strong> </a>
361
+
362
+
363
+
364
+ </span>
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+ <span class="summary_desc"><div class='inline'><p>The name of the current executable.</p>
375
+ </div></span>
376
+
377
+ </li>
378
+
379
+
380
+ <li class="public ">
381
+ <span class="summary_signature">
382
+
383
+ <a href="#execute-instance_method" title="#execute (instance method)">- (Object) <strong>execute</strong>(args = nil) </a>
384
+
385
+
386
+
387
+ </span>
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+ <span class="summary_desc"><div class='inline'><p>Executes this application.</p>
398
+ </div></span>
399
+
400
+ </li>
401
+
402
+
403
+ <li class="public ">
404
+ <span class="summary_signature">
405
+
406
+ <a href="#help_option-instance_method" title="#help_option (instance method)">- (Object) <strong>help_option</strong> </a>
407
+
408
+
409
+
410
+ </span>
411
+
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
+ <span class="summary_desc"><div class='inline'><p>Adds a help command and a help option to this application.</p>
421
+ </div></span>
422
+
423
+ </li>
424
+
425
+
426
+ <li class="public ">
427
+ <span class="summary_signature">
428
+
429
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Application) <strong>initialize</strong>(options = {}, &amp;block) </a>
430
+
431
+
432
+
433
+ </span>
434
+
435
+
436
+ <span class="note title constructor">constructor</span>
437
+
438
+
439
+
440
+
441
+
442
+
443
+
444
+
445
+ <span class="summary_desc"><div class='inline'><p>Creates a new application.</p>
446
+ </div></span>
447
+
448
+ </li>
449
+
450
+
451
+ <li class="public ">
452
+ <span class="summary_signature">
453
+
454
+ <a href="#run-instance_method" title="#run (instance method)">- (Hash) <strong>run</strong>(command, message = nil, show_exit = true, fatal = true) </a>
455
+
456
+
457
+
458
+ </span>
459
+
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+
468
+ <span class="summary_desc"><div class='inline'><p>Runs a command into the shell.</p>
469
+ </div></span>
470
+
471
+ </li>
472
+
473
+
474
+ </ul>
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+
484
+
485
+
486
+ <h3 class="inherited">Methods inherited from <span class='object_link'><a href="Command.html" title="Bovem::Command (class)">Command</a></span></h3>
487
+ <p class="inherited"><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#has_banner%3F-instance_method" title="Bovem::Command#has_banner? (method)">#has_banner?</a></span>, <span class='object_link'><a href="Command.html#has_description%3F-instance_method" title="Bovem::Command#has_description? (method)">#has_description?</a></span>, <span class='object_link'><a href="Command.html#is_application%3F-instance_method" title="Bovem::Command#is_application? (method)">#is_application?</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>
488
+
489
+
490
+
491
+
492
+
493
+
494
+
495
+
496
+
497
+ <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>
498
+ <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#get_options-instance_method" title="Bovem::CommandMethods::Children#get_options (method)">#get_options</a></span>, <span class='object_link'><a href="CommandMethods/Children.html#has_commands%3F-instance_method" title="Bovem::CommandMethods::Children#has_commands? (method)">#has_commands?</a></span>, <span class='object_link'><a href="CommandMethods/Children.html#has_options%3F-instance_method" title="Bovem::CommandMethods::Children#has_options? (method)">#has_options?</a></span>, <span class='object_link'><a href="CommandMethods/Children.html#option-instance_method" title="Bovem::CommandMethods::Children#option (method)">#option</a></span></p>
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+
508
+ <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>
509
+ <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>
510
+
511
+ <div id="constructor_details" class="method_details_list">
512
+ <h2>Constructor Details</h2>
513
+
514
+ <div class="method_details first">
515
+ <h3 class="signature first" id="initialize-instance_method">
516
+
517
+ - (<tt><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></tt>) <strong>initialize</strong>(options = {}, &amp;block)
518
+
519
+
520
+
521
+
522
+
523
+ </h3><div class="docstring">
524
+ <div class="discussion">
525
+ <p>Creates a new application.</p>
526
+
527
+
528
+ </div>
529
+ </div>
530
+ <div class="tags">
531
+ <p class="tag_title">Parameters:</p>
532
+ <ul class="param">
533
+
534
+ <li>
535
+
536
+ <span class='name'>options</span>
537
+
538
+
539
+ <span class='type'>(<tt>Hash</tt>)</span>
540
+
541
+
542
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
543
+
544
+
545
+ &mdash;
546
+ <div class='inline'><p>The settings to initialize the application with.</p>
547
+ </div>
548
+
549
+ </li>
550
+
551
+ </ul>
552
+
553
+
554
+ </div><table class="source_code">
555
+ <tr>
556
+ <td>
557
+ <pre class="lines">
558
+
559
+
560
+ 55
561
+ 56
562
+ 57
563
+ 58
564
+ 59
565
+ 60
566
+ 61
567
+ 62
568
+ 63
569
+ 64
570
+ 65</pre>
571
+ </td>
572
+ <td>
573
+ <pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 55</span>
574
+
575
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
576
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
577
+
578
+ <span class='ivar'>@shell</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Shell</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
579
+ <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>
580
+ <span class='ivar'>@skip_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
581
+ <span class='ivar'>@show_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
582
+ <span class='ivar'>@output_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
583
+
584
+ <span class='id identifier rubyid_help_option'>help_option</span>
585
+ <span class='kw'>end</span></pre>
586
+ </td>
587
+ </tr>
588
+ </table>
589
+ </div>
590
+
591
+ </div>
592
+
593
+ <div id="instance_attr_details" class="attr_details">
594
+ <h2>Instance Attribute Details</h2>
595
+
596
+
597
+ <span id="console=-instance_method"></span>
598
+ <div class="method_details first">
599
+ <h3 class="signature first" id="console-instance_method">
600
+
601
+ - (<tt><span class='object_link'><a href="Console.html" title="Bovem::Console (class)">Bovem::Console</a></span></tt>) <strong>console</strong>
602
+
603
+
604
+
605
+
606
+
607
+ </h3><div class="docstring">
608
+ <div class="discussion">
609
+ <p>Returns A console helper.</p>
610
+
611
+
612
+ </div>
613
+ </div>
614
+ <div class="tags">
615
+
616
+ <p class="tag_title">Returns:</p>
617
+ <ul class="return">
618
+
619
+ <li>
620
+
621
+
622
+ <span class='type'>(<tt><span class='object_link'><a href="Console.html" title="Bovem::Console (class)">Bovem::Console</a></span></tt>)</span>
623
+
624
+
625
+
626
+ &mdash;
627
+ <div class='inline'><p>A console helper.</p>
628
+ </div>
629
+
630
+ </li>
631
+
632
+ </ul>
633
+
634
+ </div><table class="source_code">
635
+ <tr>
636
+ <td>
637
+ <pre class="lines">
638
+
639
+
640
+ 24
641
+ 25
642
+ 26
643
+ 27
644
+ 28
645
+ 29
646
+ 30
647
+ 31
648
+ 32
649
+ 33
650
+ 34
651
+ 35
652
+ 36
653
+ 37
654
+ 38
655
+ 39
656
+ 40
657
+ 41
658
+ 42
659
+ 43
660
+ 44
661
+ 45
662
+ 46
663
+ 47
664
+ 48
665
+ 49
666
+ 50
667
+ 51
668
+ 52
669
+ 53
670
+ 54
671
+ 55
672
+ 56
673
+ 57
674
+ 58
675
+ 59
676
+ 60
677
+ 61
678
+ 62
679
+ 63
680
+ 64
681
+ 65
682
+ 66
683
+ 67
684
+ 68
685
+ 69
686
+ 70
687
+ 71
688
+ 72
689
+ 73
690
+ 74
691
+ 75
692
+ 76
693
+ 77
694
+ 78
695
+ 79
696
+ 80
697
+ 81
698
+ 82
699
+ 83
700
+ 84
701
+ 85
702
+ 86
703
+ 87
704
+ 88
705
+ 89
706
+ 90
707
+ 91
708
+ 92
709
+ 93
710
+ 94
711
+ 95
712
+ 96
713
+ 97
714
+ 98
715
+ 99
716
+ 100
717
+ 101
718
+ 102
719
+ 103
720
+ 104
721
+ 105
722
+ 106
723
+ 107
724
+ 108
725
+ 109
726
+ 110
727
+ 111
728
+ 112
729
+ 113
730
+ 114
731
+ 115
732
+ 116
733
+ 117
734
+ 118
735
+ 119
736
+ 120
737
+ 121
738
+ 122
739
+ 123
740
+ 124
741
+ 125
742
+ 126
743
+ 127
744
+ 128
745
+ 129
746
+ 130
747
+ 131
748
+ 132
749
+ 133
750
+ 134
751
+ 135
752
+ 136
753
+ 137
754
+ 138
755
+ 139
756
+ 140
757
+ 141
758
+ 142
759
+ 143
760
+ 144
761
+ 145
762
+ 146
763
+ 147
764
+ 148
765
+ 149
766
+ 150
767
+ 151
768
+ 152
769
+ 153
770
+ 154
771
+ 155
772
+ 156
773
+ 157</pre>
774
+ </td>
775
+ <td>
776
+ <pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 24</span>
777
+
778
+ <span class='kw'>class</span> <span class='const'>Application</span> <span class='op'>&lt;</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Command</span>
779
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:version</span>
780
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:shell</span>
781
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:console</span>
782
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:skip_commands</span>
783
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:show_commands</span>
784
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:output_commands</span>
785
+
786
+ <span class='comment'># Initializes a new Bovem application.
787
+ </span> <span class='comment'>#
788
+ </span> <span class='comment'># In options, you can override the command line arguments with `:__args__`, and you can skip execution by specifying `run: false`.
789
+ </span> <span class='comment'>#
790
+ </span> <span class='comment'># @see Command#setup_with
791
+ </span> <span class='comment'>#
792
+ </span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
793
+ </span> <span class='comment'># @return [Application] The created application.
794
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
795
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Application</span><span class='comma'>,</span> <span class='symbol'>:missing_block</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Localizer</span><span class='period'>.</span><span class='id identifier rubyid_localize_on_locale'>localize_on_locale</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='symbol'>:missing_app_block</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_block_given?'>block_given?</span>
796
+ <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>
797
+
798
+ <span class='kw'>begin</span>
799
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
800
+ <span class='kw'>rescue</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
801
+ <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>
802
+ <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>
803
+ <span class='kw'>end</span>
804
+ <span class='kw'>end</span>
805
+
806
+ <span class='comment'># Creates a new application.
807
+ </span> <span class='comment'>#
808
+ </span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
809
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
810
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
811
+
812
+ <span class='ivar'>@shell</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Shell</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
813
+ <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>
814
+ <span class='ivar'>@skip_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
815
+ <span class='ivar'>@show_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
816
+ <span class='ivar'>@output_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
817
+
818
+ <span class='id identifier rubyid_help_option'>help_option</span>
819
+ <span class='kw'>end</span>
820
+
821
+ <span class='comment'># Reads and optionally sets the version of this application.
822
+ </span> <span class='comment'>#
823
+ </span> <span class='comment'># @param value [String|nil] The new version of this application.
824
+ </span> <span class='comment'># @return [String|nil] The version of this application.
825
+ </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>
826
+ <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'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
827
+ <span class='ivar'>@version</span>
828
+ <span class='kw'>end</span>
829
+
830
+ <span class='comment'># Executes this application.
831
+ </span> <span class='comment'>#
832
+ </span> <span class='comment'># @param args [Array] The command line to pass to this application. Defaults to `ARGV`.
833
+ </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>
834
+ <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>
835
+ <span class='kw'>end</span>
836
+
837
+ <span class='comment'># Adds a help command and a help option to this application.
838
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_help_option'>help_option</span>
839
+ <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>
840
+ <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>
841
+ <span class='kw'>end</span>
842
+
843
+ <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>
844
+ <span class='kw'>end</span>
845
+
846
+ <span class='comment'># The name of the current executable.
847
+ </span> <span class='comment'>#
848
+ </span> <span class='comment'># @return [String] The name of the current executable.
849
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_executable_name'>executable_name</span>
850
+ <span class='gvar'>$0</span>
851
+ <span class='kw'>end</span>
852
+
853
+ <span class='comment'># Shows a help about a command.
854
+ </span> <span class='comment'>#
855
+ </span> <span class='comment'># @param command [Command] The command to show help for.
856
+ </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>
857
+ <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>
858
+ <span class='comment'># Find the command across
859
+ </span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</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='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
860
+
861
+ <span class='kw'>if</span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='kw'>then</span>
862
+ <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>
863
+ <span class='kw'>else</span>
864
+ <span class='kw'>break</span>
865
+ <span class='kw'>end</span>
866
+ <span class='kw'>end</span>
867
+
868
+ <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span>
869
+ <span class='kw'>end</span>
870
+
871
+ <span class='comment'># Runs a command into the shell.
872
+ </span> <span class='comment'>#
873
+ </span> <span class='comment'># @param command [String] The string to run.
874
+ </span> <span class='comment'># @param message [String] A message to show before running.
875
+ </span> <span class='comment'># @param show_exit [Boolean] If show the exit status.
876
+ </span> <span class='comment'># @param fatal [Boolean] If quit in case of fatal errors.
877
+ </span> <span class='comment'># @return [Hash] An hash with `status` and `output` keys.
878
+ </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>
879
+ <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>
880
+ <span class='kw'>end</span>
881
+
882
+ <span class='id identifier rubyid_private'>private</span>
883
+ <span class='comment'># Setup options for application creation.
884
+ </span> <span class='comment'>#
885
+ </span> <span class='comment'># @param options [Hash] The options to setups.
886
+ </span> <span class='comment'># @return [Array] If to run the application, the arguments and the specified options.
887
+ </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>
888
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='label'>name:</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Localizer</span><span class='period'>.</span><span class='id identifier rubyid_localize_on_locale'>localize_on_locale</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='symbol'>:default_application_name</span><span class='rparen'>)</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='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>
889
+ <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>
890
+ <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>
891
+ <span class='kw'>end</span>
892
+
893
+ <span class='comment'># Create the application.
894
+ </span> <span class='comment'>#
895
+ </span> <span class='comment'># @param run [Boolean ]If to run the application.
896
+ </span> <span class='comment'># @param args [Hash] The arguments to use for running.
897
+ </span> <span class='comment'># @param options [Hash] The options of the application.
898
+ </span> <span class='comment'># @return [Application] The new application.
899
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
900
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
901
+ <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'>&amp;&amp;</span> <span class='id identifier rubyid_run'>run</span>
902
+ <span class='id identifier rubyid_application'>application</span>
903
+ <span class='kw'>end</span>
904
+
905
+ <span class='comment'># Fetch a command list for showing help.
906
+ </span> <span class='comment'>#
907
+ </span> <span class='comment'># @param command [Command] The command to show help for.
908
+ </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>
909
+ <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_collect'>collect</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'>&quot;</span><span class='tstring_content'>:</span><span class='tstring_end'>&quot;</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_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</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'>&amp;</span><span class='symbol'>:present?</span><span class='rparen'>)</span>
910
+ <span class='kw'>end</span>
911
+ <span class='kw'>end</span></pre>
912
+ </td>
913
+ </tr>
914
+ </table>
915
+ </div>
916
+
917
+
918
+ <span id="output_commands=-instance_method"></span>
919
+ <div class="method_details ">
920
+ <h3 class="signature " id="output_commands-instance_method">
921
+
922
+ - (<tt>Boolean</tt>) <strong>output_commands</strong>
923
+
924
+
925
+
926
+
927
+
928
+ </h3><div class="docstring">
929
+ <div class="discussion">
930
+ <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>
931
+
932
+
933
+ </div>
934
+ </div>
935
+ <div class="tags">
936
+
937
+ <p class="tag_title">Returns:</p>
938
+ <ul class="return">
939
+
940
+ <li>
941
+
942
+
943
+ <span class='type'>(<tt>Boolean</tt>)</span>
944
+
945
+
946
+
947
+ &mdash;
948
+ <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>
949
+ </div>
950
+
951
+ </li>
952
+
953
+ </ul>
954
+
955
+ </div><table class="source_code">
956
+ <tr>
957
+ <td>
958
+ <pre class="lines">
959
+
960
+
961
+ 24
962
+ 25
963
+ 26
964
+ 27
965
+ 28
966
+ 29
967
+ 30
968
+ 31
969
+ 32
970
+ 33
971
+ 34
972
+ 35
973
+ 36
974
+ 37
975
+ 38
976
+ 39
977
+ 40
978
+ 41
979
+ 42
980
+ 43
981
+ 44
982
+ 45
983
+ 46
984
+ 47
985
+ 48
986
+ 49
987
+ 50
988
+ 51
989
+ 52
990
+ 53
991
+ 54
992
+ 55
993
+ 56
994
+ 57
995
+ 58
996
+ 59
997
+ 60
998
+ 61
999
+ 62
1000
+ 63
1001
+ 64
1002
+ 65
1003
+ 66
1004
+ 67
1005
+ 68
1006
+ 69
1007
+ 70
1008
+ 71
1009
+ 72
1010
+ 73
1011
+ 74
1012
+ 75
1013
+ 76
1014
+ 77
1015
+ 78
1016
+ 79
1017
+ 80
1018
+ 81
1019
+ 82
1020
+ 83
1021
+ 84
1022
+ 85
1023
+ 86
1024
+ 87
1025
+ 88
1026
+ 89
1027
+ 90
1028
+ 91
1029
+ 92
1030
+ 93
1031
+ 94
1032
+ 95
1033
+ 96
1034
+ 97
1035
+ 98
1036
+ 99
1037
+ 100
1038
+ 101
1039
+ 102
1040
+ 103
1041
+ 104
1042
+ 105
1043
+ 106
1044
+ 107
1045
+ 108
1046
+ 109
1047
+ 110
1048
+ 111
1049
+ 112
1050
+ 113
1051
+ 114
1052
+ 115
1053
+ 116
1054
+ 117
1055
+ 118
1056
+ 119
1057
+ 120
1058
+ 121
1059
+ 122
1060
+ 123
1061
+ 124
1062
+ 125
1063
+ 126
1064
+ 127
1065
+ 128
1066
+ 129
1067
+ 130
1068
+ 131
1069
+ 132
1070
+ 133
1071
+ 134
1072
+ 135
1073
+ 136
1074
+ 137
1075
+ 138
1076
+ 139
1077
+ 140
1078
+ 141
1079
+ 142
1080
+ 143
1081
+ 144
1082
+ 145
1083
+ 146
1084
+ 147
1085
+ 148
1086
+ 149
1087
+ 150
1088
+ 151
1089
+ 152
1090
+ 153
1091
+ 154
1092
+ 155
1093
+ 156
1094
+ 157</pre>
1095
+ </td>
1096
+ <td>
1097
+ <pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 24</span>
1098
+
1099
+ <span class='kw'>class</span> <span class='const'>Application</span> <span class='op'>&lt;</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Command</span>
1100
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:version</span>
1101
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:shell</span>
1102
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:console</span>
1103
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:skip_commands</span>
1104
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:show_commands</span>
1105
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:output_commands</span>
1106
+
1107
+ <span class='comment'># Initializes a new Bovem application.
1108
+ </span> <span class='comment'>#
1109
+ </span> <span class='comment'># In options, you can override the command line arguments with `:__args__`, and you can skip execution by specifying `run: false`.
1110
+ </span> <span class='comment'>#
1111
+ </span> <span class='comment'># @see Command#setup_with
1112
+ </span> <span class='comment'>#
1113
+ </span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
1114
+ </span> <span class='comment'># @return [Application] The created application.
1115
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1116
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Application</span><span class='comma'>,</span> <span class='symbol'>:missing_block</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Localizer</span><span class='period'>.</span><span class='id identifier rubyid_localize_on_locale'>localize_on_locale</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='symbol'>:missing_app_block</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_block_given?'>block_given?</span>
1117
+ <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>
1118
+
1119
+ <span class='kw'>begin</span>
1120
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1121
+ <span class='kw'>rescue</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
1122
+ <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>
1123
+ <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>
1124
+ <span class='kw'>end</span>
1125
+ <span class='kw'>end</span>
1126
+
1127
+ <span class='comment'># Creates a new application.
1128
+ </span> <span class='comment'>#
1129
+ </span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
1130
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1131
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1132
+
1133
+ <span class='ivar'>@shell</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Shell</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
1134
+ <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>
1135
+ <span class='ivar'>@skip_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
1136
+ <span class='ivar'>@show_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
1137
+ <span class='ivar'>@output_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
1138
+
1139
+ <span class='id identifier rubyid_help_option'>help_option</span>
1140
+ <span class='kw'>end</span>
1141
+
1142
+ <span class='comment'># Reads and optionally sets the version of this application.
1143
+ </span> <span class='comment'>#
1144
+ </span> <span class='comment'># @param value [String|nil] The new version of this application.
1145
+ </span> <span class='comment'># @return [String|nil] The version of this application.
1146
+ </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>
1147
+ <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'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
1148
+ <span class='ivar'>@version</span>
1149
+ <span class='kw'>end</span>
1150
+
1151
+ <span class='comment'># Executes this application.
1152
+ </span> <span class='comment'>#
1153
+ </span> <span class='comment'># @param args [Array] The command line to pass to this application. Defaults to `ARGV`.
1154
+ </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>
1155
+ <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>
1156
+ <span class='kw'>end</span>
1157
+
1158
+ <span class='comment'># Adds a help command and a help option to this application.
1159
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_help_option'>help_option</span>
1160
+ <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>
1161
+ <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>
1162
+ <span class='kw'>end</span>
1163
+
1164
+ <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>
1165
+ <span class='kw'>end</span>
1166
+
1167
+ <span class='comment'># The name of the current executable.
1168
+ </span> <span class='comment'>#
1169
+ </span> <span class='comment'># @return [String] The name of the current executable.
1170
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_executable_name'>executable_name</span>
1171
+ <span class='gvar'>$0</span>
1172
+ <span class='kw'>end</span>
1173
+
1174
+ <span class='comment'># Shows a help about a command.
1175
+ </span> <span class='comment'>#
1176
+ </span> <span class='comment'># @param command [Command] The command to show help for.
1177
+ </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>
1178
+ <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>
1179
+ <span class='comment'># Find the command across
1180
+ </span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</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='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
1181
+
1182
+ <span class='kw'>if</span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='kw'>then</span>
1183
+ <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>
1184
+ <span class='kw'>else</span>
1185
+ <span class='kw'>break</span>
1186
+ <span class='kw'>end</span>
1187
+ <span class='kw'>end</span>
1188
+
1189
+ <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span>
1190
+ <span class='kw'>end</span>
1191
+
1192
+ <span class='comment'># Runs a command into the shell.
1193
+ </span> <span class='comment'>#
1194
+ </span> <span class='comment'># @param command [String] The string to run.
1195
+ </span> <span class='comment'># @param message [String] A message to show before running.
1196
+ </span> <span class='comment'># @param show_exit [Boolean] If show the exit status.
1197
+ </span> <span class='comment'># @param fatal [Boolean] If quit in case of fatal errors.
1198
+ </span> <span class='comment'># @return [Hash] An hash with `status` and `output` keys.
1199
+ </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>
1200
+ <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>
1201
+ <span class='kw'>end</span>
1202
+
1203
+ <span class='id identifier rubyid_private'>private</span>
1204
+ <span class='comment'># Setup options for application creation.
1205
+ </span> <span class='comment'>#
1206
+ </span> <span class='comment'># @param options [Hash] The options to setups.
1207
+ </span> <span class='comment'># @return [Array] If to run the application, the arguments and the specified options.
1208
+ </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>
1209
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='label'>name:</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Localizer</span><span class='period'>.</span><span class='id identifier rubyid_localize_on_locale'>localize_on_locale</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='symbol'>:default_application_name</span><span class='rparen'>)</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='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>
1210
+ <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>
1211
+ <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>
1212
+ <span class='kw'>end</span>
1213
+
1214
+ <span class='comment'># Create the application.
1215
+ </span> <span class='comment'>#
1216
+ </span> <span class='comment'># @param run [Boolean ]If to run the application.
1217
+ </span> <span class='comment'># @param args [Hash] The arguments to use for running.
1218
+ </span> <span class='comment'># @param options [Hash] The options of the application.
1219
+ </span> <span class='comment'># @return [Application] The new application.
1220
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1221
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1222
+ <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'>&amp;&amp;</span> <span class='id identifier rubyid_run'>run</span>
1223
+ <span class='id identifier rubyid_application'>application</span>
1224
+ <span class='kw'>end</span>
1225
+
1226
+ <span class='comment'># Fetch a command list for showing help.
1227
+ </span> <span class='comment'>#
1228
+ </span> <span class='comment'># @param command [Command] The command to show help for.
1229
+ </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>
1230
+ <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_collect'>collect</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'>&quot;</span><span class='tstring_content'>:</span><span class='tstring_end'>&quot;</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_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</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'>&amp;</span><span class='symbol'>:present?</span><span class='rparen'>)</span>
1231
+ <span class='kw'>end</span>
1232
+ <span class='kw'>end</span></pre>
1233
+ </td>
1234
+ </tr>
1235
+ </table>
1236
+ </div>
1237
+
1238
+
1239
+ <span id="shell=-instance_method"></span>
1240
+ <div class="method_details ">
1241
+ <h3 class="signature " id="shell-instance_method">
1242
+
1243
+ - (<tt><span class='object_link'><a href="Shell.html" title="Bovem::Shell (class)">Bovem::Shell</a></span></tt>) <strong>shell</strong>
1244
+
1245
+
1246
+
1247
+
1248
+
1249
+ </h3><div class="docstring">
1250
+ <div class="discussion">
1251
+ <p>Returns A shell helper.</p>
1252
+
1253
+
1254
+ </div>
1255
+ </div>
1256
+ <div class="tags">
1257
+
1258
+ <p class="tag_title">Returns:</p>
1259
+ <ul class="return">
1260
+
1261
+ <li>
1262
+
1263
+
1264
+ <span class='type'>(<tt><span class='object_link'><a href="Shell.html" title="Bovem::Shell (class)">Bovem::Shell</a></span></tt>)</span>
1265
+
1266
+
1267
+
1268
+ &mdash;
1269
+ <div class='inline'><p>A shell helper.</p>
1270
+ </div>
1271
+
1272
+ </li>
1273
+
1274
+ </ul>
1275
+
1276
+ </div><table class="source_code">
1277
+ <tr>
1278
+ <td>
1279
+ <pre class="lines">
1280
+
1281
+
1282
+ 24
1283
+ 25
1284
+ 26
1285
+ 27
1286
+ 28
1287
+ 29
1288
+ 30
1289
+ 31
1290
+ 32
1291
+ 33
1292
+ 34
1293
+ 35
1294
+ 36
1295
+ 37
1296
+ 38
1297
+ 39
1298
+ 40
1299
+ 41
1300
+ 42
1301
+ 43
1302
+ 44
1303
+ 45
1304
+ 46
1305
+ 47
1306
+ 48
1307
+ 49
1308
+ 50
1309
+ 51
1310
+ 52
1311
+ 53
1312
+ 54
1313
+ 55
1314
+ 56
1315
+ 57
1316
+ 58
1317
+ 59
1318
+ 60
1319
+ 61
1320
+ 62
1321
+ 63
1322
+ 64
1323
+ 65
1324
+ 66
1325
+ 67
1326
+ 68
1327
+ 69
1328
+ 70
1329
+ 71
1330
+ 72
1331
+ 73
1332
+ 74
1333
+ 75
1334
+ 76
1335
+ 77
1336
+ 78
1337
+ 79
1338
+ 80
1339
+ 81
1340
+ 82
1341
+ 83
1342
+ 84
1343
+ 85
1344
+ 86
1345
+ 87
1346
+ 88
1347
+ 89
1348
+ 90
1349
+ 91
1350
+ 92
1351
+ 93
1352
+ 94
1353
+ 95
1354
+ 96
1355
+ 97
1356
+ 98
1357
+ 99
1358
+ 100
1359
+ 101
1360
+ 102
1361
+ 103
1362
+ 104
1363
+ 105
1364
+ 106
1365
+ 107
1366
+ 108
1367
+ 109
1368
+ 110
1369
+ 111
1370
+ 112
1371
+ 113
1372
+ 114
1373
+ 115
1374
+ 116
1375
+ 117
1376
+ 118
1377
+ 119
1378
+ 120
1379
+ 121
1380
+ 122
1381
+ 123
1382
+ 124
1383
+ 125
1384
+ 126
1385
+ 127
1386
+ 128
1387
+ 129
1388
+ 130
1389
+ 131
1390
+ 132
1391
+ 133
1392
+ 134
1393
+ 135
1394
+ 136
1395
+ 137
1396
+ 138
1397
+ 139
1398
+ 140
1399
+ 141
1400
+ 142
1401
+ 143
1402
+ 144
1403
+ 145
1404
+ 146
1405
+ 147
1406
+ 148
1407
+ 149
1408
+ 150
1409
+ 151
1410
+ 152
1411
+ 153
1412
+ 154
1413
+ 155
1414
+ 156
1415
+ 157</pre>
1416
+ </td>
1417
+ <td>
1418
+ <pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 24</span>
1419
+
1420
+ <span class='kw'>class</span> <span class='const'>Application</span> <span class='op'>&lt;</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Command</span>
1421
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:version</span>
1422
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:shell</span>
1423
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:console</span>
1424
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:skip_commands</span>
1425
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:show_commands</span>
1426
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:output_commands</span>
1427
+
1428
+ <span class='comment'># Initializes a new Bovem application.
1429
+ </span> <span class='comment'>#
1430
+ </span> <span class='comment'># In options, you can override the command line arguments with `:__args__`, and you can skip execution by specifying `run: false`.
1431
+ </span> <span class='comment'>#
1432
+ </span> <span class='comment'># @see Command#setup_with
1433
+ </span> <span class='comment'>#
1434
+ </span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
1435
+ </span> <span class='comment'># @return [Application] The created application.
1436
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1437
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Application</span><span class='comma'>,</span> <span class='symbol'>:missing_block</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Localizer</span><span class='period'>.</span><span class='id identifier rubyid_localize_on_locale'>localize_on_locale</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='symbol'>:missing_app_block</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_block_given?'>block_given?</span>
1438
+ <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>
1439
+
1440
+ <span class='kw'>begin</span>
1441
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1442
+ <span class='kw'>rescue</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
1443
+ <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>
1444
+ <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>
1445
+ <span class='kw'>end</span>
1446
+ <span class='kw'>end</span>
1447
+
1448
+ <span class='comment'># Creates a new application.
1449
+ </span> <span class='comment'>#
1450
+ </span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
1451
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1452
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1453
+
1454
+ <span class='ivar'>@shell</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Shell</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
1455
+ <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>
1456
+ <span class='ivar'>@skip_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
1457
+ <span class='ivar'>@show_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
1458
+ <span class='ivar'>@output_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
1459
+
1460
+ <span class='id identifier rubyid_help_option'>help_option</span>
1461
+ <span class='kw'>end</span>
1462
+
1463
+ <span class='comment'># Reads and optionally sets the version of this application.
1464
+ </span> <span class='comment'>#
1465
+ </span> <span class='comment'># @param value [String|nil] The new version of this application.
1466
+ </span> <span class='comment'># @return [String|nil] The version of this application.
1467
+ </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>
1468
+ <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'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
1469
+ <span class='ivar'>@version</span>
1470
+ <span class='kw'>end</span>
1471
+
1472
+ <span class='comment'># Executes this application.
1473
+ </span> <span class='comment'>#
1474
+ </span> <span class='comment'># @param args [Array] The command line to pass to this application. Defaults to `ARGV`.
1475
+ </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>
1476
+ <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>
1477
+ <span class='kw'>end</span>
1478
+
1479
+ <span class='comment'># Adds a help command and a help option to this application.
1480
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_help_option'>help_option</span>
1481
+ <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>
1482
+ <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>
1483
+ <span class='kw'>end</span>
1484
+
1485
+ <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>
1486
+ <span class='kw'>end</span>
1487
+
1488
+ <span class='comment'># The name of the current executable.
1489
+ </span> <span class='comment'>#
1490
+ </span> <span class='comment'># @return [String] The name of the current executable.
1491
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_executable_name'>executable_name</span>
1492
+ <span class='gvar'>$0</span>
1493
+ <span class='kw'>end</span>
1494
+
1495
+ <span class='comment'># Shows a help about a command.
1496
+ </span> <span class='comment'>#
1497
+ </span> <span class='comment'># @param command [Command] The command to show help for.
1498
+ </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>
1499
+ <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>
1500
+ <span class='comment'># Find the command across
1501
+ </span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</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='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
1502
+
1503
+ <span class='kw'>if</span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='kw'>then</span>
1504
+ <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>
1505
+ <span class='kw'>else</span>
1506
+ <span class='kw'>break</span>
1507
+ <span class='kw'>end</span>
1508
+ <span class='kw'>end</span>
1509
+
1510
+ <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span>
1511
+ <span class='kw'>end</span>
1512
+
1513
+ <span class='comment'># Runs a command into the shell.
1514
+ </span> <span class='comment'>#
1515
+ </span> <span class='comment'># @param command [String] The string to run.
1516
+ </span> <span class='comment'># @param message [String] A message to show before running.
1517
+ </span> <span class='comment'># @param show_exit [Boolean] If show the exit status.
1518
+ </span> <span class='comment'># @param fatal [Boolean] If quit in case of fatal errors.
1519
+ </span> <span class='comment'># @return [Hash] An hash with `status` and `output` keys.
1520
+ </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>
1521
+ <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>
1522
+ <span class='kw'>end</span>
1523
+
1524
+ <span class='id identifier rubyid_private'>private</span>
1525
+ <span class='comment'># Setup options for application creation.
1526
+ </span> <span class='comment'>#
1527
+ </span> <span class='comment'># @param options [Hash] The options to setups.
1528
+ </span> <span class='comment'># @return [Array] If to run the application, the arguments and the specified options.
1529
+ </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>
1530
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='label'>name:</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Localizer</span><span class='period'>.</span><span class='id identifier rubyid_localize_on_locale'>localize_on_locale</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='symbol'>:default_application_name</span><span class='rparen'>)</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='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>
1531
+ <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>
1532
+ <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>
1533
+ <span class='kw'>end</span>
1534
+
1535
+ <span class='comment'># Create the application.
1536
+ </span> <span class='comment'>#
1537
+ </span> <span class='comment'># @param run [Boolean ]If to run the application.
1538
+ </span> <span class='comment'># @param args [Hash] The arguments to use for running.
1539
+ </span> <span class='comment'># @param options [Hash] The options of the application.
1540
+ </span> <span class='comment'># @return [Application] The new application.
1541
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1542
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1543
+ <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'>&amp;&amp;</span> <span class='id identifier rubyid_run'>run</span>
1544
+ <span class='id identifier rubyid_application'>application</span>
1545
+ <span class='kw'>end</span>
1546
+
1547
+ <span class='comment'># Fetch a command list for showing help.
1548
+ </span> <span class='comment'>#
1549
+ </span> <span class='comment'># @param command [Command] The command to show help for.
1550
+ </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>
1551
+ <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_collect'>collect</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'>&quot;</span><span class='tstring_content'>:</span><span class='tstring_end'>&quot;</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_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</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'>&amp;</span><span class='symbol'>:present?</span><span class='rparen'>)</span>
1552
+ <span class='kw'>end</span>
1553
+ <span class='kw'>end</span></pre>
1554
+ </td>
1555
+ </tr>
1556
+ </table>
1557
+ </div>
1558
+
1559
+
1560
+ <span id="show_commands=-instance_method"></span>
1561
+ <div class="method_details ">
1562
+ <h3 class="signature " id="show_commands-instance_method">
1563
+
1564
+ - (<tt>Boolean</tt>) <strong>show_commands</strong>
1565
+
1566
+
1567
+
1568
+
1569
+
1570
+ </h3><div class="docstring">
1571
+ <div class="discussion">
1572
+ <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>
1573
+
1574
+
1575
+ </div>
1576
+ </div>
1577
+ <div class="tags">
1578
+
1579
+ <p class="tag_title">Returns:</p>
1580
+ <ul class="return">
1581
+
1582
+ <li>
1583
+
1584
+
1585
+ <span class='type'>(<tt>Boolean</tt>)</span>
1586
+
1587
+
1588
+
1589
+ &mdash;
1590
+ <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>
1591
+ </div>
1592
+
1593
+ </li>
1594
+
1595
+ </ul>
1596
+
1597
+ </div><table class="source_code">
1598
+ <tr>
1599
+ <td>
1600
+ <pre class="lines">
1601
+
1602
+
1603
+ 24
1604
+ 25
1605
+ 26
1606
+ 27
1607
+ 28
1608
+ 29
1609
+ 30
1610
+ 31
1611
+ 32
1612
+ 33
1613
+ 34
1614
+ 35
1615
+ 36
1616
+ 37
1617
+ 38
1618
+ 39
1619
+ 40
1620
+ 41
1621
+ 42
1622
+ 43
1623
+ 44
1624
+ 45
1625
+ 46
1626
+ 47
1627
+ 48
1628
+ 49
1629
+ 50
1630
+ 51
1631
+ 52
1632
+ 53
1633
+ 54
1634
+ 55
1635
+ 56
1636
+ 57
1637
+ 58
1638
+ 59
1639
+ 60
1640
+ 61
1641
+ 62
1642
+ 63
1643
+ 64
1644
+ 65
1645
+ 66
1646
+ 67
1647
+ 68
1648
+ 69
1649
+ 70
1650
+ 71
1651
+ 72
1652
+ 73
1653
+ 74
1654
+ 75
1655
+ 76
1656
+ 77
1657
+ 78
1658
+ 79
1659
+ 80
1660
+ 81
1661
+ 82
1662
+ 83
1663
+ 84
1664
+ 85
1665
+ 86
1666
+ 87
1667
+ 88
1668
+ 89
1669
+ 90
1670
+ 91
1671
+ 92
1672
+ 93
1673
+ 94
1674
+ 95
1675
+ 96
1676
+ 97
1677
+ 98
1678
+ 99
1679
+ 100
1680
+ 101
1681
+ 102
1682
+ 103
1683
+ 104
1684
+ 105
1685
+ 106
1686
+ 107
1687
+ 108
1688
+ 109
1689
+ 110
1690
+ 111
1691
+ 112
1692
+ 113
1693
+ 114
1694
+ 115
1695
+ 116
1696
+ 117
1697
+ 118
1698
+ 119
1699
+ 120
1700
+ 121
1701
+ 122
1702
+ 123
1703
+ 124
1704
+ 125
1705
+ 126
1706
+ 127
1707
+ 128
1708
+ 129
1709
+ 130
1710
+ 131
1711
+ 132
1712
+ 133
1713
+ 134
1714
+ 135
1715
+ 136
1716
+ 137
1717
+ 138
1718
+ 139
1719
+ 140
1720
+ 141
1721
+ 142
1722
+ 143
1723
+ 144
1724
+ 145
1725
+ 146
1726
+ 147
1727
+ 148
1728
+ 149
1729
+ 150
1730
+ 151
1731
+ 152
1732
+ 153
1733
+ 154
1734
+ 155
1735
+ 156
1736
+ 157</pre>
1737
+ </td>
1738
+ <td>
1739
+ <pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 24</span>
1740
+
1741
+ <span class='kw'>class</span> <span class='const'>Application</span> <span class='op'>&lt;</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Command</span>
1742
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:version</span>
1743
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:shell</span>
1744
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:console</span>
1745
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:skip_commands</span>
1746
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:show_commands</span>
1747
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:output_commands</span>
1748
+
1749
+ <span class='comment'># Initializes a new Bovem application.
1750
+ </span> <span class='comment'>#
1751
+ </span> <span class='comment'># In options, you can override the command line arguments with `:__args__`, and you can skip execution by specifying `run: false`.
1752
+ </span> <span class='comment'>#
1753
+ </span> <span class='comment'># @see Command#setup_with
1754
+ </span> <span class='comment'>#
1755
+ </span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
1756
+ </span> <span class='comment'># @return [Application] The created application.
1757
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1758
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Application</span><span class='comma'>,</span> <span class='symbol'>:missing_block</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Localizer</span><span class='period'>.</span><span class='id identifier rubyid_localize_on_locale'>localize_on_locale</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='symbol'>:missing_app_block</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_block_given?'>block_given?</span>
1759
+ <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>
1760
+
1761
+ <span class='kw'>begin</span>
1762
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1763
+ <span class='kw'>rescue</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
1764
+ <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>
1765
+ <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>
1766
+ <span class='kw'>end</span>
1767
+ <span class='kw'>end</span>
1768
+
1769
+ <span class='comment'># Creates a new application.
1770
+ </span> <span class='comment'>#
1771
+ </span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
1772
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1773
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1774
+
1775
+ <span class='ivar'>@shell</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Shell</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
1776
+ <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>
1777
+ <span class='ivar'>@skip_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
1778
+ <span class='ivar'>@show_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
1779
+ <span class='ivar'>@output_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
1780
+
1781
+ <span class='id identifier rubyid_help_option'>help_option</span>
1782
+ <span class='kw'>end</span>
1783
+
1784
+ <span class='comment'># Reads and optionally sets the version of this application.
1785
+ </span> <span class='comment'>#
1786
+ </span> <span class='comment'># @param value [String|nil] The new version of this application.
1787
+ </span> <span class='comment'># @return [String|nil] The version of this application.
1788
+ </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>
1789
+ <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'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
1790
+ <span class='ivar'>@version</span>
1791
+ <span class='kw'>end</span>
1792
+
1793
+ <span class='comment'># Executes this application.
1794
+ </span> <span class='comment'>#
1795
+ </span> <span class='comment'># @param args [Array] The command line to pass to this application. Defaults to `ARGV`.
1796
+ </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>
1797
+ <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>
1798
+ <span class='kw'>end</span>
1799
+
1800
+ <span class='comment'># Adds a help command and a help option to this application.
1801
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_help_option'>help_option</span>
1802
+ <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>
1803
+ <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>
1804
+ <span class='kw'>end</span>
1805
+
1806
+ <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>
1807
+ <span class='kw'>end</span>
1808
+
1809
+ <span class='comment'># The name of the current executable.
1810
+ </span> <span class='comment'>#
1811
+ </span> <span class='comment'># @return [String] The name of the current executable.
1812
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_executable_name'>executable_name</span>
1813
+ <span class='gvar'>$0</span>
1814
+ <span class='kw'>end</span>
1815
+
1816
+ <span class='comment'># Shows a help about a command.
1817
+ </span> <span class='comment'>#
1818
+ </span> <span class='comment'># @param command [Command] The command to show help for.
1819
+ </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>
1820
+ <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>
1821
+ <span class='comment'># Find the command across
1822
+ </span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</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='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
1823
+
1824
+ <span class='kw'>if</span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='kw'>then</span>
1825
+ <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>
1826
+ <span class='kw'>else</span>
1827
+ <span class='kw'>break</span>
1828
+ <span class='kw'>end</span>
1829
+ <span class='kw'>end</span>
1830
+
1831
+ <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span>
1832
+ <span class='kw'>end</span>
1833
+
1834
+ <span class='comment'># Runs a command into the shell.
1835
+ </span> <span class='comment'>#
1836
+ </span> <span class='comment'># @param command [String] The string to run.
1837
+ </span> <span class='comment'># @param message [String] A message to show before running.
1838
+ </span> <span class='comment'># @param show_exit [Boolean] If show the exit status.
1839
+ </span> <span class='comment'># @param fatal [Boolean] If quit in case of fatal errors.
1840
+ </span> <span class='comment'># @return [Hash] An hash with `status` and `output` keys.
1841
+ </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>
1842
+ <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>
1843
+ <span class='kw'>end</span>
1844
+
1845
+ <span class='id identifier rubyid_private'>private</span>
1846
+ <span class='comment'># Setup options for application creation.
1847
+ </span> <span class='comment'>#
1848
+ </span> <span class='comment'># @param options [Hash] The options to setups.
1849
+ </span> <span class='comment'># @return [Array] If to run the application, the arguments and the specified options.
1850
+ </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>
1851
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='label'>name:</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Localizer</span><span class='period'>.</span><span class='id identifier rubyid_localize_on_locale'>localize_on_locale</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='symbol'>:default_application_name</span><span class='rparen'>)</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='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>
1852
+ <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>
1853
+ <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>
1854
+ <span class='kw'>end</span>
1855
+
1856
+ <span class='comment'># Create the application.
1857
+ </span> <span class='comment'>#
1858
+ </span> <span class='comment'># @param run [Boolean ]If to run the application.
1859
+ </span> <span class='comment'># @param args [Hash] The arguments to use for running.
1860
+ </span> <span class='comment'># @param options [Hash] The options of the application.
1861
+ </span> <span class='comment'># @return [Application] The new application.
1862
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1863
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1864
+ <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'>&amp;&amp;</span> <span class='id identifier rubyid_run'>run</span>
1865
+ <span class='id identifier rubyid_application'>application</span>
1866
+ <span class='kw'>end</span>
1867
+
1868
+ <span class='comment'># Fetch a command list for showing help.
1869
+ </span> <span class='comment'>#
1870
+ </span> <span class='comment'># @param command [Command] The command to show help for.
1871
+ </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>
1872
+ <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_collect'>collect</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'>&quot;</span><span class='tstring_content'>:</span><span class='tstring_end'>&quot;</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_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</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'>&amp;</span><span class='symbol'>:present?</span><span class='rparen'>)</span>
1873
+ <span class='kw'>end</span>
1874
+ <span class='kw'>end</span></pre>
1875
+ </td>
1876
+ </tr>
1877
+ </table>
1878
+ </div>
1879
+
1880
+
1881
+ <span id="skip_commands=-instance_method"></span>
1882
+ <div class="method_details ">
1883
+ <h3 class="signature " id="skip_commands-instance_method">
1884
+
1885
+ - (<tt>Boolean</tt>) <strong>skip_commands</strong>
1886
+
1887
+
1888
+
1889
+
1890
+
1891
+ </h3><div class="docstring">
1892
+ <div class="discussion">
1893
+ <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>
1894
+
1895
+
1896
+ </div>
1897
+ </div>
1898
+ <div class="tags">
1899
+
1900
+ <p class="tag_title">Returns:</p>
1901
+ <ul class="return">
1902
+
1903
+ <li>
1904
+
1905
+
1906
+ <span class='type'>(<tt>Boolean</tt>)</span>
1907
+
1908
+
1909
+
1910
+ &mdash;
1911
+ <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>
1912
+ </div>
1913
+
1914
+ </li>
1915
+
1916
+ </ul>
1917
+
1918
+ </div><table class="source_code">
1919
+ <tr>
1920
+ <td>
1921
+ <pre class="lines">
1922
+
1923
+
1924
+ 24
1925
+ 25
1926
+ 26
1927
+ 27
1928
+ 28
1929
+ 29
1930
+ 30
1931
+ 31
1932
+ 32
1933
+ 33
1934
+ 34
1935
+ 35
1936
+ 36
1937
+ 37
1938
+ 38
1939
+ 39
1940
+ 40
1941
+ 41
1942
+ 42
1943
+ 43
1944
+ 44
1945
+ 45
1946
+ 46
1947
+ 47
1948
+ 48
1949
+ 49
1950
+ 50
1951
+ 51
1952
+ 52
1953
+ 53
1954
+ 54
1955
+ 55
1956
+ 56
1957
+ 57
1958
+ 58
1959
+ 59
1960
+ 60
1961
+ 61
1962
+ 62
1963
+ 63
1964
+ 64
1965
+ 65
1966
+ 66
1967
+ 67
1968
+ 68
1969
+ 69
1970
+ 70
1971
+ 71
1972
+ 72
1973
+ 73
1974
+ 74
1975
+ 75
1976
+ 76
1977
+ 77
1978
+ 78
1979
+ 79
1980
+ 80
1981
+ 81
1982
+ 82
1983
+ 83
1984
+ 84
1985
+ 85
1986
+ 86
1987
+ 87
1988
+ 88
1989
+ 89
1990
+ 90
1991
+ 91
1992
+ 92
1993
+ 93
1994
+ 94
1995
+ 95
1996
+ 96
1997
+ 97
1998
+ 98
1999
+ 99
2000
+ 100
2001
+ 101
2002
+ 102
2003
+ 103
2004
+ 104
2005
+ 105
2006
+ 106
2007
+ 107
2008
+ 108
2009
+ 109
2010
+ 110
2011
+ 111
2012
+ 112
2013
+ 113
2014
+ 114
2015
+ 115
2016
+ 116
2017
+ 117
2018
+ 118
2019
+ 119
2020
+ 120
2021
+ 121
2022
+ 122
2023
+ 123
2024
+ 124
2025
+ 125
2026
+ 126
2027
+ 127
2028
+ 128
2029
+ 129
2030
+ 130
2031
+ 131
2032
+ 132
2033
+ 133
2034
+ 134
2035
+ 135
2036
+ 136
2037
+ 137
2038
+ 138
2039
+ 139
2040
+ 140
2041
+ 141
2042
+ 142
2043
+ 143
2044
+ 144
2045
+ 145
2046
+ 146
2047
+ 147
2048
+ 148
2049
+ 149
2050
+ 150
2051
+ 151
2052
+ 152
2053
+ 153
2054
+ 154
2055
+ 155
2056
+ 156
2057
+ 157</pre>
2058
+ </td>
2059
+ <td>
2060
+ <pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 24</span>
2061
+
2062
+ <span class='kw'>class</span> <span class='const'>Application</span> <span class='op'>&lt;</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Command</span>
2063
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:version</span>
2064
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:shell</span>
2065
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:console</span>
2066
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:skip_commands</span>
2067
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:show_commands</span>
2068
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:output_commands</span>
2069
+
2070
+ <span class='comment'># Initializes a new Bovem application.
2071
+ </span> <span class='comment'>#
2072
+ </span> <span class='comment'># In options, you can override the command line arguments with `:__args__`, and you can skip execution by specifying `run: false`.
2073
+ </span> <span class='comment'>#
2074
+ </span> <span class='comment'># @see Command#setup_with
2075
+ </span> <span class='comment'>#
2076
+ </span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
2077
+ </span> <span class='comment'># @return [Application] The created application.
2078
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
2079
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Application</span><span class='comma'>,</span> <span class='symbol'>:missing_block</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Localizer</span><span class='period'>.</span><span class='id identifier rubyid_localize_on_locale'>localize_on_locale</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='symbol'>:missing_app_block</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_block_given?'>block_given?</span>
2080
+ <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>
2081
+
2082
+ <span class='kw'>begin</span>
2083
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
2084
+ <span class='kw'>rescue</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
2085
+ <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>
2086
+ <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>
2087
+ <span class='kw'>end</span>
2088
+ <span class='kw'>end</span>
2089
+
2090
+ <span class='comment'># Creates a new application.
2091
+ </span> <span class='comment'>#
2092
+ </span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
2093
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
2094
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
2095
+
2096
+ <span class='ivar'>@shell</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Shell</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
2097
+ <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>
2098
+ <span class='ivar'>@skip_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
2099
+ <span class='ivar'>@show_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
2100
+ <span class='ivar'>@output_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
2101
+
2102
+ <span class='id identifier rubyid_help_option'>help_option</span>
2103
+ <span class='kw'>end</span>
2104
+
2105
+ <span class='comment'># Reads and optionally sets the version of this application.
2106
+ </span> <span class='comment'>#
2107
+ </span> <span class='comment'># @param value [String|nil] The new version of this application.
2108
+ </span> <span class='comment'># @return [String|nil] The version of this application.
2109
+ </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>
2110
+ <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'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
2111
+ <span class='ivar'>@version</span>
2112
+ <span class='kw'>end</span>
2113
+
2114
+ <span class='comment'># Executes this application.
2115
+ </span> <span class='comment'>#
2116
+ </span> <span class='comment'># @param args [Array] The command line to pass to this application. Defaults to `ARGV`.
2117
+ </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>
2118
+ <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>
2119
+ <span class='kw'>end</span>
2120
+
2121
+ <span class='comment'># Adds a help command and a help option to this application.
2122
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_help_option'>help_option</span>
2123
+ <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>
2124
+ <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>
2125
+ <span class='kw'>end</span>
2126
+
2127
+ <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>
2128
+ <span class='kw'>end</span>
2129
+
2130
+ <span class='comment'># The name of the current executable.
2131
+ </span> <span class='comment'>#
2132
+ </span> <span class='comment'># @return [String] The name of the current executable.
2133
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_executable_name'>executable_name</span>
2134
+ <span class='gvar'>$0</span>
2135
+ <span class='kw'>end</span>
2136
+
2137
+ <span class='comment'># Shows a help about a command.
2138
+ </span> <span class='comment'>#
2139
+ </span> <span class='comment'># @param command [Command] The command to show help for.
2140
+ </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>
2141
+ <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>
2142
+ <span class='comment'># Find the command across
2143
+ </span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</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='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
2144
+
2145
+ <span class='kw'>if</span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='kw'>then</span>
2146
+ <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>
2147
+ <span class='kw'>else</span>
2148
+ <span class='kw'>break</span>
2149
+ <span class='kw'>end</span>
2150
+ <span class='kw'>end</span>
2151
+
2152
+ <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span>
2153
+ <span class='kw'>end</span>
2154
+
2155
+ <span class='comment'># Runs a command into the shell.
2156
+ </span> <span class='comment'>#
2157
+ </span> <span class='comment'># @param command [String] The string to run.
2158
+ </span> <span class='comment'># @param message [String] A message to show before running.
2159
+ </span> <span class='comment'># @param show_exit [Boolean] If show the exit status.
2160
+ </span> <span class='comment'># @param fatal [Boolean] If quit in case of fatal errors.
2161
+ </span> <span class='comment'># @return [Hash] An hash with `status` and `output` keys.
2162
+ </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>
2163
+ <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>
2164
+ <span class='kw'>end</span>
2165
+
2166
+ <span class='id identifier rubyid_private'>private</span>
2167
+ <span class='comment'># Setup options for application creation.
2168
+ </span> <span class='comment'>#
2169
+ </span> <span class='comment'># @param options [Hash] The options to setups.
2170
+ </span> <span class='comment'># @return [Array] If to run the application, the arguments and the specified options.
2171
+ </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>
2172
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='label'>name:</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Localizer</span><span class='period'>.</span><span class='id identifier rubyid_localize_on_locale'>localize_on_locale</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='symbol'>:default_application_name</span><span class='rparen'>)</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='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>
2173
+ <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>
2174
+ <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>
2175
+ <span class='kw'>end</span>
2176
+
2177
+ <span class='comment'># Create the application.
2178
+ </span> <span class='comment'>#
2179
+ </span> <span class='comment'># @param run [Boolean ]If to run the application.
2180
+ </span> <span class='comment'># @param args [Hash] The arguments to use for running.
2181
+ </span> <span class='comment'># @param options [Hash] The options of the application.
2182
+ </span> <span class='comment'># @return [Application] The new application.
2183
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
2184
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
2185
+ <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'>&amp;&amp;</span> <span class='id identifier rubyid_run'>run</span>
2186
+ <span class='id identifier rubyid_application'>application</span>
2187
+ <span class='kw'>end</span>
2188
+
2189
+ <span class='comment'># Fetch a command list for showing help.
2190
+ </span> <span class='comment'>#
2191
+ </span> <span class='comment'># @param command [Command] The command to show help for.
2192
+ </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>
2193
+ <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_collect'>collect</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'>&quot;</span><span class='tstring_content'>:</span><span class='tstring_end'>&quot;</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_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</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'>&amp;</span><span class='symbol'>:present?</span><span class='rparen'>)</span>
2194
+ <span class='kw'>end</span>
2195
+ <span class='kw'>end</span></pre>
2196
+ </td>
2197
+ </tr>
2198
+ </table>
2199
+ </div>
2200
+
2201
+
2202
+ <span id="version=-instance_method"></span>
2203
+ <div class="method_details ">
2204
+ <h3 class="signature " id="version-instance_method">
2205
+
2206
+ - (<tt>String|nil</tt>) <strong>version</strong>(value = nil)
2207
+
2208
+
2209
+
2210
+
2211
+
2212
+ </h3><div class="docstring">
2213
+ <div class="discussion">
2214
+ <p>Reads and optionally sets the version of this application.</p>
2215
+
2216
+
2217
+ </div>
2218
+ </div>
2219
+ <div class="tags">
2220
+ <p class="tag_title">Parameters:</p>
2221
+ <ul class="param">
2222
+
2223
+ <li>
2224
+
2225
+ <span class='name'>value</span>
2226
+
2227
+
2228
+ <span class='type'>(<tt>String|nil</tt>)</span>
2229
+
2230
+
2231
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
2232
+
2233
+
2234
+ &mdash;
2235
+ <div class='inline'><p>The new version of this application.</p>
2236
+ </div>
2237
+
2238
+ </li>
2239
+
2240
+ </ul>
2241
+
2242
+ <p class="tag_title">Returns:</p>
2243
+ <ul class="return">
2244
+
2245
+ <li>
2246
+
2247
+
2248
+ <span class='type'>(<tt>String|nil</tt>)</span>
2249
+
2250
+
2251
+
2252
+ &mdash;
2253
+ <div class='inline'><p>The version of this application.</p>
2254
+ </div>
2255
+
2256
+ </li>
2257
+
2258
+ </ul>
2259
+
2260
+ </div><table class="source_code">
2261
+ <tr>
2262
+ <td>
2263
+ <pre class="lines">
2264
+
2265
+
2266
+ 24
2267
+ 25
2268
+ 26
2269
+ 27
2270
+ 28
2271
+ 29
2272
+ 30
2273
+ 31
2274
+ 32
2275
+ 33
2276
+ 34
2277
+ 35
2278
+ 36
2279
+ 37
2280
+ 38
2281
+ 39
2282
+ 40
2283
+ 41
2284
+ 42
2285
+ 43
2286
+ 44
2287
+ 45
2288
+ 46
2289
+ 47
2290
+ 48
2291
+ 49
2292
+ 50
2293
+ 51
2294
+ 52
2295
+ 53
2296
+ 54
2297
+ 55
2298
+ 56
2299
+ 57
2300
+ 58
2301
+ 59
2302
+ 60
2303
+ 61
2304
+ 62
2305
+ 63
2306
+ 64
2307
+ 65
2308
+ 66
2309
+ 67
2310
+ 68
2311
+ 69
2312
+ 70
2313
+ 71
2314
+ 72
2315
+ 73
2316
+ 74
2317
+ 75
2318
+ 76
2319
+ 77
2320
+ 78
2321
+ 79
2322
+ 80
2323
+ 81
2324
+ 82
2325
+ 83
2326
+ 84
2327
+ 85
2328
+ 86
2329
+ 87
2330
+ 88
2331
+ 89
2332
+ 90
2333
+ 91
2334
+ 92
2335
+ 93
2336
+ 94
2337
+ 95
2338
+ 96
2339
+ 97
2340
+ 98
2341
+ 99
2342
+ 100
2343
+ 101
2344
+ 102
2345
+ 103
2346
+ 104
2347
+ 105
2348
+ 106
2349
+ 107
2350
+ 108
2351
+ 109
2352
+ 110
2353
+ 111
2354
+ 112
2355
+ 113
2356
+ 114
2357
+ 115
2358
+ 116
2359
+ 117
2360
+ 118
2361
+ 119
2362
+ 120
2363
+ 121
2364
+ 122
2365
+ 123
2366
+ 124
2367
+ 125
2368
+ 126
2369
+ 127
2370
+ 128
2371
+ 129
2372
+ 130
2373
+ 131
2374
+ 132
2375
+ 133
2376
+ 134
2377
+ 135
2378
+ 136
2379
+ 137
2380
+ 138
2381
+ 139
2382
+ 140
2383
+ 141
2384
+ 142
2385
+ 143
2386
+ 144
2387
+ 145
2388
+ 146
2389
+ 147
2390
+ 148
2391
+ 149
2392
+ 150
2393
+ 151
2394
+ 152
2395
+ 153
2396
+ 154
2397
+ 155
2398
+ 156
2399
+ 157</pre>
2400
+ </td>
2401
+ <td>
2402
+ <pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 24</span>
2403
+
2404
+ <span class='kw'>class</span> <span class='const'>Application</span> <span class='op'>&lt;</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Command</span>
2405
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:version</span>
2406
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:shell</span>
2407
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:console</span>
2408
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:skip_commands</span>
2409
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:show_commands</span>
2410
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:output_commands</span>
2411
+
2412
+ <span class='comment'># Initializes a new Bovem application.
2413
+ </span> <span class='comment'>#
2414
+ </span> <span class='comment'># In options, you can override the command line arguments with `:__args__`, and you can skip execution by specifying `run: false`.
2415
+ </span> <span class='comment'>#
2416
+ </span> <span class='comment'># @see Command#setup_with
2417
+ </span> <span class='comment'>#
2418
+ </span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
2419
+ </span> <span class='comment'># @return [Application] The created application.
2420
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
2421
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Application</span><span class='comma'>,</span> <span class='symbol'>:missing_block</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Localizer</span><span class='period'>.</span><span class='id identifier rubyid_localize_on_locale'>localize_on_locale</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='symbol'>:missing_app_block</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_block_given?'>block_given?</span>
2422
+ <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>
2423
+
2424
+ <span class='kw'>begin</span>
2425
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
2426
+ <span class='kw'>rescue</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
2427
+ <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>
2428
+ <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>
2429
+ <span class='kw'>end</span>
2430
+ <span class='kw'>end</span>
2431
+
2432
+ <span class='comment'># Creates a new application.
2433
+ </span> <span class='comment'>#
2434
+ </span> <span class='comment'># @param options [Hash] The settings to initialize the application with.
2435
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
2436
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
2437
+
2438
+ <span class='ivar'>@shell</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Shell</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
2439
+ <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>
2440
+ <span class='ivar'>@skip_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
2441
+ <span class='ivar'>@show_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
2442
+ <span class='ivar'>@output_commands</span> <span class='op'>=</span> <span class='kw'>false</span>
2443
+
2444
+ <span class='id identifier rubyid_help_option'>help_option</span>
2445
+ <span class='kw'>end</span>
2446
+
2447
+ <span class='comment'># Reads and optionally sets the version of this application.
2448
+ </span> <span class='comment'>#
2449
+ </span> <span class='comment'># @param value [String|nil] The new version of this application.
2450
+ </span> <span class='comment'># @return [String|nil] The version of this application.
2451
+ </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>
2452
+ <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'>if</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
2453
+ <span class='ivar'>@version</span>
2454
+ <span class='kw'>end</span>
2455
+
2456
+ <span class='comment'># Executes this application.
2457
+ </span> <span class='comment'>#
2458
+ </span> <span class='comment'># @param args [Array] The command line to pass to this application. Defaults to `ARGV`.
2459
+ </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>
2460
+ <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>
2461
+ <span class='kw'>end</span>
2462
+
2463
+ <span class='comment'># Adds a help command and a help option to this application.
2464
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_help_option'>help_option</span>
2465
+ <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>
2466
+ <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>
2467
+ <span class='kw'>end</span>
2468
+
2469
+ <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>
2470
+ <span class='kw'>end</span>
2471
+
2472
+ <span class='comment'># The name of the current executable.
2473
+ </span> <span class='comment'>#
2474
+ </span> <span class='comment'># @return [String] The name of the current executable.
2475
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_executable_name'>executable_name</span>
2476
+ <span class='gvar'>$0</span>
2477
+ <span class='kw'>end</span>
2478
+
2479
+ <span class='comment'># Shows a help about a command.
2480
+ </span> <span class='comment'>#
2481
+ </span> <span class='comment'># @param command [Command] The command to show help for.
2482
+ </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>
2483
+ <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>
2484
+ <span class='comment'># Find the command across
2485
+ </span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</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='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
2486
+
2487
+ <span class='kw'>if</span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='kw'>then</span>
2488
+ <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>
2489
+ <span class='kw'>else</span>
2490
+ <span class='kw'>break</span>
2491
+ <span class='kw'>end</span>
2492
+ <span class='kw'>end</span>
2493
+
2494
+ <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span>
2495
+ <span class='kw'>end</span>
2496
+
2497
+ <span class='comment'># Runs a command into the shell.
2498
+ </span> <span class='comment'>#
2499
+ </span> <span class='comment'># @param command [String] The string to run.
2500
+ </span> <span class='comment'># @param message [String] A message to show before running.
2501
+ </span> <span class='comment'># @param show_exit [Boolean] If show the exit status.
2502
+ </span> <span class='comment'># @param fatal [Boolean] If quit in case of fatal errors.
2503
+ </span> <span class='comment'># @return [Hash] An hash with `status` and `output` keys.
2504
+ </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>
2505
+ <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>
2506
+ <span class='kw'>end</span>
2507
+
2508
+ <span class='id identifier rubyid_private'>private</span>
2509
+ <span class='comment'># Setup options for application creation.
2510
+ </span> <span class='comment'>#
2511
+ </span> <span class='comment'># @param options [Hash] The options to setups.
2512
+ </span> <span class='comment'># @return [Array] If to run the application, the arguments and the specified options.
2513
+ </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>
2514
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='label'>name:</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Localizer</span><span class='period'>.</span><span class='id identifier rubyid_localize_on_locale'>localize_on_locale</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='symbol'>:default_application_name</span><span class='rparen'>)</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='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>
2515
+ <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>
2516
+ <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>
2517
+ <span class='kw'>end</span>
2518
+
2519
+ <span class='comment'># Create the application.
2520
+ </span> <span class='comment'>#
2521
+ </span> <span class='comment'># @param run [Boolean ]If to run the application.
2522
+ </span> <span class='comment'># @param args [Hash] The arguments to use for running.
2523
+ </span> <span class='comment'># @param options [Hash] The options of the application.
2524
+ </span> <span class='comment'># @return [Application] The new application.
2525
+ </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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
2526
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
2527
+ <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'>&amp;&amp;</span> <span class='id identifier rubyid_run'>run</span>
2528
+ <span class='id identifier rubyid_application'>application</span>
2529
+ <span class='kw'>end</span>
2530
+
2531
+ <span class='comment'># Fetch a command list for showing help.
2532
+ </span> <span class='comment'>#
2533
+ </span> <span class='comment'># @param command [Command] The command to show help for.
2534
+ </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>
2535
+ <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_collect'>collect</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'>&quot;</span><span class='tstring_content'>:</span><span class='tstring_end'>&quot;</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_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</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'>&amp;</span><span class='symbol'>:present?</span><span class='rparen'>)</span>
2536
+ <span class='kw'>end</span>
2537
+ <span class='kw'>end</span></pre>
2538
+ </td>
2539
+ </tr>
2540
+ </table>
2541
+ </div>
2542
+
2543
+ </div>
2544
+
2545
+
2546
+ <div id="class_method_details" class="method_details_list">
2547
+ <h2>Class Method Details</h2>
2548
+
2549
+
2550
+ <div class="method_details first">
2551
+ <h3 class="signature first" id="create-class_method">
2552
+
2553
+ + (<tt><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></tt>) <strong>create</strong>(options = {}, &amp;block)
2554
+
2555
+
2556
+
2557
+
2558
+
2559
+ </h3><div class="docstring">
2560
+ <div class="discussion">
2561
+ <p>Initializes a new Bovem application.</p>
2562
+
2563
+ <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>
2564
+
2565
+
2566
+ </div>
2567
+ </div>
2568
+ <div class="tags">
2569
+ <p class="tag_title">Parameters:</p>
2570
+ <ul class="param">
2571
+
2572
+ <li>
2573
+
2574
+ <span class='name'>options</span>
2575
+
2576
+
2577
+ <span class='type'>(<tt>Hash</tt>)</span>
2578
+
2579
+
2580
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
2581
+
2582
+
2583
+ &mdash;
2584
+ <div class='inline'><p>The settings to initialize the application with.</p>
2585
+ </div>
2586
+
2587
+ </li>
2588
+
2589
+ </ul>
2590
+
2591
+ <p class="tag_title">Returns:</p>
2592
+ <ul class="return">
2593
+
2594
+ <li>
2595
+
2596
+
2597
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Bovem::Application (class)">Application</a></span></tt>)</span>
2598
+
2599
+
2600
+
2601
+ &mdash;
2602
+ <div class='inline'><p>The created application.</p>
2603
+ </div>
2604
+
2605
+ </li>
2606
+
2607
+ </ul>
2608
+ <p class="tag_title">Raises:</p>
2609
+ <ul class="raise">
2610
+
2611
+ <li>
2612
+
2613
+
2614
+ <span class='type'>(<tt><span class='object_link'><a href="Errors/Error.html" title="Bovem::Errors::Error (class)">Bovem::Errors::Error</a></span></tt>)</span>
2615
+
2616
+
2617
+
2618
+ </li>
2619
+
2620
+ </ul>
2621
+
2622
+ <p class="tag_title">See Also:</p>
2623
+ <ul class="see">
2624
+
2625
+ <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>
2626
+
2627
+ </ul>
2628
+
2629
+ </div><table class="source_code">
2630
+ <tr>
2631
+ <td>
2632
+ <pre class="lines">
2633
+
2634
+
2635
+ 40
2636
+ 41
2637
+ 42
2638
+ 43
2639
+ 44
2640
+ 45
2641
+ 46
2642
+ 47
2643
+ 48
2644
+ 49
2645
+ 50</pre>
2646
+ </td>
2647
+ <td>
2648
+ <pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 40</span>
2649
+
2650
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
2651
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>Error</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Application</span><span class='comma'>,</span> <span class='symbol'>:missing_block</span><span class='comma'>,</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Localizer</span><span class='period'>.</span><span class='id identifier rubyid_localize_on_locale'>localize_on_locale</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='symbol'>:missing_app_block</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_block_given?'>block_given?</span>
2652
+ <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>
2653
+
2654
+ <span class='kw'>begin</span>
2655
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
2656
+ <span class='kw'>rescue</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
2657
+ <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>
2658
+ <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>
2659
+ <span class='kw'>end</span>
2660
+ <span class='kw'>end</span></pre>
2661
+ </td>
2662
+ </tr>
2663
+ </table>
2664
+ </div>
2665
+
2666
+ </div>
2667
+
2668
+ <div id="instance_method_details" class="method_details_list">
2669
+ <h2>Instance Method Details</h2>
2670
+
2671
+
2672
+ <div class="method_details first">
2673
+ <h3 class="signature first" id="command_help-instance_method">
2674
+
2675
+ - (<tt>Object</tt>) <strong>command_help</strong>(command)
2676
+
2677
+
2678
+
2679
+
2680
+
2681
+ </h3><div class="docstring">
2682
+ <div class="discussion">
2683
+ <p>Shows a help about a command.</p>
2684
+
2685
+
2686
+ </div>
2687
+ </div>
2688
+ <div class="tags">
2689
+ <p class="tag_title">Parameters:</p>
2690
+ <ul class="param">
2691
+
2692
+ <li>
2693
+
2694
+ <span class='name'>command</span>
2695
+
2696
+
2697
+ <span class='type'>(<tt><span class='object_link'><a href="Command.html" title="Bovem::Command (class)">Command</a></span></tt>)</span>
2698
+
2699
+
2700
+
2701
+ &mdash;
2702
+ <div class='inline'><p>The command to show help for.</p>
2703
+ </div>
2704
+
2705
+ </li>
2706
+
2707
+ </ul>
2708
+
2709
+
2710
+ </div><table class="source_code">
2711
+ <tr>
2712
+ <td>
2713
+ <pre class="lines">
2714
+
2715
+
2716
+ 102
2717
+ 103
2718
+ 104
2719
+ 105
2720
+ 106
2721
+ 107
2722
+ 108
2723
+ 109
2724
+ 110
2725
+ 111
2726
+ 112
2727
+ 113
2728
+ 114
2729
+ 115</pre>
2730
+ </td>
2731
+ <td>
2732
+ <pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 102</span>
2733
+
2734
+ <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>
2735
+ <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>
2736
+ <span class='comment'># Find the command across
2737
+ </span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Parser</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='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
2738
+
2739
+ <span class='kw'>if</span> <span class='id identifier rubyid_next_command'>next_command</span> <span class='kw'>then</span>
2740
+ <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>
2741
+ <span class='kw'>else</span>
2742
+ <span class='kw'>break</span>
2743
+ <span class='kw'>end</span>
2744
+ <span class='kw'>end</span>
2745
+
2746
+ <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_show_help'>show_help</span>
2747
+ <span class='kw'>end</span></pre>
2748
+ </td>
2749
+ </tr>
2750
+ </table>
2751
+ </div>
2752
+
2753
+ <div class="method_details ">
2754
+ <h3 class="signature " id="executable_name-instance_method">
2755
+
2756
+ - (<tt>String</tt>) <strong>executable_name</strong>
2757
+
2758
+
2759
+
2760
+
2761
+
2762
+ </h3><div class="docstring">
2763
+ <div class="discussion">
2764
+ <p>The name of the current executable.</p>
2765
+
2766
+
2767
+ </div>
2768
+ </div>
2769
+ <div class="tags">
2770
+
2771
+ <p class="tag_title">Returns:</p>
2772
+ <ul class="return">
2773
+
2774
+ <li>
2775
+
2776
+
2777
+ <span class='type'>(<tt>String</tt>)</span>
2778
+
2779
+
2780
+
2781
+ &mdash;
2782
+ <div class='inline'><p>The name of the current executable.</p>
2783
+ </div>
2784
+
2785
+ </li>
2786
+
2787
+ </ul>
2788
+
2789
+ </div><table class="source_code">
2790
+ <tr>
2791
+ <td>
2792
+ <pre class="lines">
2793
+
2794
+
2795
+ 95
2796
+ 96
2797
+ 97</pre>
2798
+ </td>
2799
+ <td>
2800
+ <pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 95</span>
2801
+
2802
+ <span class='kw'>def</span> <span class='id identifier rubyid_executable_name'>executable_name</span>
2803
+ <span class='gvar'>$0</span>
2804
+ <span class='kw'>end</span></pre>
2805
+ </td>
2806
+ </tr>
2807
+ </table>
2808
+ </div>
2809
+
2810
+ <div class="method_details ">
2811
+ <h3 class="signature " id="execute-instance_method">
2812
+
2813
+ - (<tt>Object</tt>) <strong>execute</strong>(args = nil)
2814
+
2815
+
2816
+
2817
+
2818
+
2819
+ </h3><div class="docstring">
2820
+ <div class="discussion">
2821
+ <p>Executes this application.</p>
2822
+
2823
+
2824
+ </div>
2825
+ </div>
2826
+ <div class="tags">
2827
+ <p class="tag_title">Parameters:</p>
2828
+ <ul class="param">
2829
+
2830
+ <li>
2831
+
2832
+ <span class='name'>args</span>
2833
+
2834
+
2835
+ <span class='type'>(<tt>Array</tt>)</span>
2836
+
2837
+
2838
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
2839
+
2840
+
2841
+ &mdash;
2842
+ <div class='inline'><p>The command line to pass to this application. Defaults to <code>ARGV</code>.</p>
2843
+ </div>
2844
+
2845
+ </li>
2846
+
2847
+ </ul>
2848
+
2849
+
2850
+ </div><table class="source_code">
2851
+ <tr>
2852
+ <td>
2853
+ <pre class="lines">
2854
+
2855
+
2856
+ 79
2857
+ 80
2858
+ 81</pre>
2859
+ </td>
2860
+ <td>
2861
+ <pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 79</span>
2862
+
2863
+ <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>
2864
+ <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>
2865
+ <span class='kw'>end</span></pre>
2866
+ </td>
2867
+ </tr>
2868
+ </table>
2869
+ </div>
2870
+
2871
+ <div class="method_details ">
2872
+ <h3 class="signature " id="help_option-instance_method">
2873
+
2874
+ - (<tt>Object</tt>) <strong>help_option</strong>
2875
+
2876
+
2877
+
2878
+
2879
+
2880
+ </h3><div class="docstring">
2881
+ <div class="discussion">
2882
+ <p>Adds a help command and a help option to this application.</p>
2883
+
2884
+
2885
+ </div>
2886
+ </div>
2887
+ <div class="tags">
2888
+
2889
+
2890
+ </div><table class="source_code">
2891
+ <tr>
2892
+ <td>
2893
+ <pre class="lines">
2894
+
2895
+
2896
+ 84
2897
+ 85
2898
+ 86
2899
+ 87
2900
+ 88
2901
+ 89
2902
+ 90</pre>
2903
+ </td>
2904
+ <td>
2905
+ <pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 84</span>
2906
+
2907
+ <span class='kw'>def</span> <span class='id identifier rubyid_help_option'>help_option</span>
2908
+ <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>
2909
+ <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>
2910
+ <span class='kw'>end</span>
2911
+
2912
+ <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>
2913
+ <span class='kw'>end</span></pre>
2914
+ </td>
2915
+ </tr>
2916
+ </table>
2917
+ </div>
2918
+
2919
+ <div class="method_details ">
2920
+ <h3 class="signature " id="run-instance_method">
2921
+
2922
+ - (<tt>Hash</tt>) <strong>run</strong>(command, message = nil, show_exit = true, fatal = true)
2923
+
2924
+
2925
+
2926
+
2927
+
2928
+ </h3><div class="docstring">
2929
+ <div class="discussion">
2930
+ <p>Runs a command into the shell.</p>
2931
+
2932
+
2933
+ </div>
2934
+ </div>
2935
+ <div class="tags">
2936
+ <p class="tag_title">Parameters:</p>
2937
+ <ul class="param">
2938
+
2939
+ <li>
2940
+
2941
+ <span class='name'>command</span>
2942
+
2943
+
2944
+ <span class='type'>(<tt>String</tt>)</span>
2945
+
2946
+
2947
+
2948
+ &mdash;
2949
+ <div class='inline'><p>The string to run.</p>
2950
+ </div>
2951
+
2952
+ </li>
2953
+
2954
+ <li>
2955
+
2956
+ <span class='name'>message</span>
2957
+
2958
+
2959
+ <span class='type'>(<tt>String</tt>)</span>
2960
+
2961
+
2962
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
2963
+
2964
+
2965
+ &mdash;
2966
+ <div class='inline'><p>A message to show before running.</p>
2967
+ </div>
2968
+
2969
+ </li>
2970
+
2971
+ <li>
2972
+
2973
+ <span class='name'>show_exit</span>
2974
+
2975
+
2976
+ <span class='type'>(<tt>Boolean</tt>)</span>
2977
+
2978
+
2979
+ <em class="default">(defaults to: <tt>true</tt>)</em>
2980
+
2981
+
2982
+ &mdash;
2983
+ <div class='inline'><p>If show the exit status.</p>
2984
+ </div>
2985
+
2986
+ </li>
2987
+
2988
+ <li>
2989
+
2990
+ <span class='name'>fatal</span>
2991
+
2992
+
2993
+ <span class='type'>(<tt>Boolean</tt>)</span>
2994
+
2995
+
2996
+ <em class="default">(defaults to: <tt>true</tt>)</em>
2997
+
2998
+
2999
+ &mdash;
3000
+ <div class='inline'><p>If quit in case of fatal errors.</p>
3001
+ </div>
3002
+
3003
+ </li>
3004
+
3005
+ </ul>
3006
+
3007
+ <p class="tag_title">Returns:</p>
3008
+ <ul class="return">
3009
+
3010
+ <li>
3011
+
3012
+
3013
+ <span class='type'>(<tt>Hash</tt>)</span>
3014
+
3015
+
3016
+
3017
+ &mdash;
3018
+ <div class='inline'><p>An hash with <code>status</code> and <code>output</code> keys.</p>
3019
+ </div>
3020
+
3021
+ </li>
3022
+
3023
+ </ul>
3024
+
3025
+ </div><table class="source_code">
3026
+ <tr>
3027
+ <td>
3028
+ <pre class="lines">
3029
+
3030
+
3031
+ 124
3032
+ 125
3033
+ 126</pre>
3034
+ </td>
3035
+ <td>
3036
+ <pre class="code"><span class="info file"># File 'lib/bovem/application.rb', line 124</span>
3037
+
3038
+ <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>
3039
+ <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>
3040
+ <span class='kw'>end</span></pre>
3041
+ </td>
3042
+ </tr>
3043
+ </table>
3044
+ </div>
3045
+
3046
+ </div>
3047
+
3048
+ </div>
3049
+
3050
+ <div id="footer">
3051
+ Generated on Sat Aug 3 13:50:17 2013 by
3052
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
3053
+ 0.8.7 (ruby-2.0.0).
3054
+ </div>
3055
+
3056
+ </body>
3057
+ </html>