cliutils 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/.gitignore +1 -0
  4. data/Gemfile +4 -0
  5. data/Gemfile.lock +48 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +288 -0
  8. data/README.rdoc +19 -0
  9. data/Rakefile +45 -0
  10. data/bin/cliutils +38 -0
  11. data/cliutils.gemspec +28 -0
  12. data/features/cli_manager.feature +13 -0
  13. data/features/step_definitions/cli_manager_steps.rb +1 -0
  14. data/features/support/env.rb +16 -0
  15. data/html/CLIUtils/Configuration.html +271 -0
  16. data/html/CLIUtils/Configurator.html +504 -0
  17. data/html/CLIUtils/LoggerDelegator.html +344 -0
  18. data/html/CLIUtils/Messenging.html +284 -0
  19. data/html/CLIUtils/Prefs.html +330 -0
  20. data/html/CLIUtils/PrettyIO.html +799 -0
  21. data/html/CLIUtils.html +112 -0
  22. data/html/Hash.html +453 -0
  23. data/html/Logger.html +183 -0
  24. data/html/Object.html +120 -0
  25. data/html/README_md.html +454 -0
  26. data/html/String.html +413 -0
  27. data/html/created.rid +13 -0
  28. data/html/fonts/Lato-Light.ttf +0 -0
  29. data/html/fonts/Lato-LightItalic.ttf +0 -0
  30. data/html/fonts/Lato-Regular.ttf +0 -0
  31. data/html/fonts/Lato-RegularItalic.ttf +0 -0
  32. data/html/fonts/SourceCodePro-Bold.ttf +0 -0
  33. data/html/fonts/SourceCodePro-Regular.ttf +0 -0
  34. data/html/fonts.css +167 -0
  35. data/html/images/add.png +0 -0
  36. data/html/images/arrow_up.png +0 -0
  37. data/html/images/brick.png +0 -0
  38. data/html/images/brick_link.png +0 -0
  39. data/html/images/bug.png +0 -0
  40. data/html/images/bullet_black.png +0 -0
  41. data/html/images/bullet_toggle_minus.png +0 -0
  42. data/html/images/bullet_toggle_plus.png +0 -0
  43. data/html/images/date.png +0 -0
  44. data/html/images/delete.png +0 -0
  45. data/html/images/find.png +0 -0
  46. data/html/images/loadingAnimation.gif +0 -0
  47. data/html/images/macFFBgHack.png +0 -0
  48. data/html/images/package.png +0 -0
  49. data/html/images/page_green.png +0 -0
  50. data/html/images/page_white_text.png +0 -0
  51. data/html/images/page_white_width.png +0 -0
  52. data/html/images/plugin.png +0 -0
  53. data/html/images/ruby.png +0 -0
  54. data/html/images/tag_blue.png +0 -0
  55. data/html/images/tag_green.png +0 -0
  56. data/html/images/transparent.png +0 -0
  57. data/html/images/wrench.png +0 -0
  58. data/html/images/wrench_orange.png +0 -0
  59. data/html/images/zoom.png +0 -0
  60. data/html/index.html +455 -0
  61. data/html/js/darkfish.js +140 -0
  62. data/html/js/jquery.js +18 -0
  63. data/html/js/navigation.js +142 -0
  64. data/html/js/search.js +109 -0
  65. data/html/js/search_index.js +1 -0
  66. data/html/js/searcher.js +228 -0
  67. data/html/rdoc.css +580 -0
  68. data/html/table_of_contents.html +399 -0
  69. data/lib/.DS_Store +0 -0
  70. data/lib/cliutils/configuration.rb +48 -0
  71. data/lib/cliutils/configurator.rb +119 -0
  72. data/lib/cliutils/ext/Hash+Extensions.rb +145 -0
  73. data/lib/cliutils/ext/Logger+Extensions.rb +27 -0
  74. data/lib/cliutils/ext/String+Extensions.rb +26 -0
  75. data/lib/cliutils/logger-delegator.rb +66 -0
  76. data/lib/cliutils/messenging.rb +51 -0
  77. data/lib/cliutils/prefs.rb +116 -0
  78. data/lib/cliutils/pretty-io.rb +255 -0
  79. data/lib/cliutils/version.rb +3 -0
  80. data/lib/cliutils.rb +15 -0
  81. data/res/readme-images/messenger-types-1.png +0 -0
  82. data/res/readme-images/messenger-warn.png +0 -0
  83. data/res/readme-images/multi-logger.png +0 -0
  84. data/res/readme-images/prettyio-color-chart.png +0 -0
  85. data/res/readme-images/prettyio-gnarly-text.png +0 -0
  86. data/res/readme-images/prettyio-red-text.png +0 -0
  87. data/res/readme-images/prompting.png +0 -0
  88. data/res/readme-images/wrapping.png +0 -0
  89. data/test/configurator_test.rb +50 -0
  90. data/test/hash_extensions_test.rb +50 -0
  91. data/test/logger_extensions_test.rb +16 -0
  92. data/test/messenging_test.rb +53 -0
  93. data/test/prefs_test.rb +29 -0
  94. data/test/string_extesions_test.rb +14 -0
  95. data/test/test_files/prefstest.yaml +33 -0
  96. metadata +199 -0
@@ -0,0 +1,454 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>README - CLIUtils</title>
8
+
9
+ <link href="./fonts.css" rel="stylesheet">
10
+ <link href="./rdoc.css" rel="stylesheet">
11
+
12
+ <script type="text/javascript">
13
+ var rdoc_rel_prefix = "./";
14
+ </script>
15
+
16
+ <script src="./js/jquery.js"></script>
17
+ <script src="./js/navigation.js"></script>
18
+ <script src="./js/search_index.js"></script>
19
+ <script src="./js/search.js"></script>
20
+ <script src="./js/searcher.js"></script>
21
+ <script src="./js/darkfish.js"></script>
22
+
23
+
24
+ <body id="top" role="document" class="file">
25
+ <nav role="navigation">
26
+ <div id="project-navigation">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
+ <h2>
29
+ <a href="./index.html" rel="home">Home</a>
30
+ </h2>
31
+
32
+ <div id="table-of-contents-navigation">
33
+ <a href="./table_of_contents.html#pages">Pages</a>
34
+ <a href="./table_of_contents.html#classes">Classes</a>
35
+ <a href="./table_of_contents.html#methods">Methods</a>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="search-section" role="search" class="project-section initially-hidden">
40
+ <form action="#" method="get" accept-charset="utf-8">
41
+ <div id="search-field-wrapper">
42
+ <input id="search-field" role="combobox" aria-label="Search"
43
+ aria-autocomplete="list" aria-controls="search-results"
44
+ type="text" name="search" placeholder="Search" spellcheck="false"
45
+ title="Type to search, Up and Down to navigate, Enter to load">
46
+ </div>
47
+
48
+ <ul id="search-results" aria-label="Search Results"
49
+ aria-busy="false" aria-expanded="false"
50
+ aria-atomic="false" class="initially-hidden"></ul>
51
+ </form>
52
+ </div>
53
+
54
+ </div>
55
+
56
+
57
+ <div class="nav-section">
58
+ <h3>Table of Contents</h3>
59
+
60
+ <ul class="link-list" role="directory">
61
+ <li><a href="#label-CLIUtils">CLIUtils</a>
62
+ <li><a href="#label-Why%3F">Why?</a>
63
+ <li><a href="#label-Installation">Installation</a>
64
+ <li><a href="#label-Usage">Usage</a>
65
+ <li><a href="#label-Libraries">Libraries</a>
66
+ <li><a href="#label-PrettyIO">PrettyIO</a>
67
+ <li><a href="#label-Messenging">Messenging</a>
68
+ <li><a href="#label-Messenging+Methods">Messenging Methods</a>
69
+ <li><a href="#label-Message+Wrapping">Message Wrapping</a>
70
+ <li><a href="#label-Prompting">Prompting</a>
71
+ <li><a href="#label-Logging">Logging</a>
72
+ <li><a href="#label-Configuration">Configuration</a>
73
+ <li><a href="#label-Loading+a+Configuration+File">Loading a Configuration File</a>
74
+ <li><a href="#label-Adding%2FRemoving+Sections">Adding/Removing Sections</a>
75
+ <li><a href="#label-Adding+Data+to+Sections">Adding Data to Sections</a>
76
+ <li><a href="#label-Saving+to+a+File">Saving to a File</a>
77
+ <li><a href="#label-Known+Issues">Known Issues</a>
78
+ <li><a href="#label-Bugs+and+Feature+Requests">Bugs and Feature Requests</a>
79
+ <li><a href="#label-Contributing">Contributing</a>
80
+ <li><a href="#label-License">License</a>
81
+ </ul>
82
+ </div>
83
+
84
+
85
+ <div id="project-metadata">
86
+ <div id="fileindex-section" class="nav-section">
87
+ <h3>Pages</h3>
88
+
89
+ <ul class="link-list">
90
+
91
+ <li><a href="./README_md.html">README</a>
92
+
93
+ </ul>
94
+ </div>
95
+
96
+ </div>
97
+ </nav>
98
+
99
+ <main role="main" aria-label="Page README.md">
100
+
101
+ <h1 id="label-CLIUtils"><a href="CLIUtils.html">CLIUtils</a><span><a href="#label-CLIUtils">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
102
+
103
+ <p><a href="CLIUtils.html">CLIUtils</a> is a library of functionality designed
104
+ to alleviate common tasks and headaches when developing command-line (CLI)
105
+ apps in Ruby.</p>
106
+
107
+ <h1 id="label-Why%3F">Why?<span><a href="#label-Why%3F">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
108
+
109
+ <p>It&#39;s fairly simple:</p>
110
+ <ol><li>
111
+ <p>I love developing Ruby-based CLI apps.</p>
112
+ </li><li>
113
+ <p>I found myself copy/pasting common code from one to another.</p>
114
+ </li><li>
115
+ <p>I decided to do something about it.</p>
116
+ </li></ol>
117
+
118
+ <h1 id="label-Installation">Installation<span><a href="#label-Installation">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
119
+
120
+ <p>Add this line to your application&#39;s Gemfile:</p>
121
+
122
+ <pre>$ gem &#39;cliutils&#39;</pre>
123
+
124
+ <p>And then execute:</p>
125
+
126
+ <pre>$ bundle</pre>
127
+
128
+ <p>Or install it yourself:</p>
129
+
130
+ <pre>$ gem install cliutils</pre>
131
+
132
+ <h1 id="label-Usage">Usage<span><a href="#label-Usage">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
133
+
134
+ <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;cliutils&#39;</span>
135
+ </pre>
136
+
137
+ <p>If you want to mix in everything that <a href="CLIUtils.html">CLIUtils</a>
138
+ has to offer:</p>
139
+
140
+ <pre>include CLIUtils</pre>
141
+
142
+ <p>Alternatively, as described below, mix in only the libraries that you want.</p>
143
+
144
+ <p>Note that although this <a href="README_md.html">README.md</a> is
145
+ extensive, it may not cover all methods. Check out the <a
146
+ href="https://github.com/bachya/cli-utils/tree/master/test">tests</a> to
147
+ see more examples.</p>
148
+
149
+ <h1 id="label-Libraries">Libraries<span><a href="#label-Libraries">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
150
+
151
+ <p><a href="CLIUtils.html">CLIUtils</a> offers:</p>
152
+ <ul><li>
153
+ <p><a href="https://github.com/bachya/cli-utils#prettyio">PrettyIO</a>:
154
+ nicer-looking CLI messages</p>
155
+ </li><li>
156
+ <p><a href="https://github.com/bachya/cli-utils#messenging">Messenging</a>: a
157
+ full-featured <a href="Logger.html">Logger</a></p>
158
+ </li><li>
159
+ <p><a
160
+ href="https://github.com/bachya/cli-utils#configuration">Configuration</a>:
161
+ a app configuration manager</p>
162
+ </li><li>
163
+ <p><a href="https://github.com/bachya/cli-utils#prefs">Prefs</a>: a
164
+ preferences prompter and manager</p>
165
+ </li></ul>
166
+
167
+ <h2 id="label-PrettyIO">PrettyIO<span><a href="#label-PrettyIO">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
168
+
169
+ <p>First stop on our journey is better client IO. To activate, simply mix into
170
+ your project:</p>
171
+
172
+ <pre class="ruby"><span class="ruby-identifier">include</span> <span class="ruby-constant">CLIUtils</span><span class="ruby-operator">::</span><span class="ruby-constant">PrettyIO</span>
173
+ </pre>
174
+
175
+ <p>PrettyIO affords you colorized strings:</p>
176
+
177
+ <pre class="ruby"><span class="ruby-identifier">puts</span> <span class="ruby-string">&#39;A sample string&#39;</span>.<span class="ruby-identifier">red</span>
178
+ </pre>
179
+
180
+ <p><img
181
+ src="https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/prettyio-red-text.png"></p>
182
+
183
+ <p>PrettyIO gives you utility methods for the common ANSI color codes:</p>
184
+
185
+ <pre class="ruby"><span class="ruby-constant">String</span>.<span class="ruby-identifier">blue</span>
186
+ <span class="ruby-constant">String</span>.<span class="ruby-identifier">cyan</span>
187
+ <span class="ruby-constant">String</span>.<span class="ruby-identifier">green</span>
188
+ <span class="ruby-constant">String</span>.<span class="ruby-identifier">purple</span>
189
+ <span class="ruby-constant">String</span>.<span class="ruby-identifier">red</span>
190
+ <span class="ruby-constant">String</span>.<span class="ruby-identifier">white</span>
191
+ <span class="ruby-constant">String</span>.<span class="ruby-identifier">yellow</span>
192
+ </pre>
193
+
194
+ <p>You also get the <code>colorize</code> method, which allows you to define
195
+ more complex color combinations. For example, to get some nice purple text
196
+ on a gnarly green background:</p>
197
+
198
+ <pre class="ruby"><span class="ruby-identifier">puts</span> <span class="ruby-string">&#39;A sample string&#39;</span>.<span class="ruby-identifier">colorize</span>(<span class="ruby-string">&#39;35;42&#39;</span>)
199
+ </pre>
200
+
201
+ <p><img
202
+ src="https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/prettyio-gnarly-text.png"></p>
203
+
204
+ <p>Naturally, memorizing the ANSI color scheme is a pain, so PrettyIO gives
205
+ you a convenient method to look up these color combinations:</p>
206
+
207
+ <pre class="ruby"><span class="ruby-identifier">color_chart</span>
208
+ </pre>
209
+
210
+ <p><img
211
+ src="https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/prettyio-color-chart.png"></p>
212
+
213
+ <h2 id="label-Messenging">Messenging<span><a href="#label-Messenging">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
214
+
215
+ <p>Throughout the life of your application, you will most likely want to send
216
+ several messages to your user (warnings, errors, info, etc.). Messenging
217
+ makes this a snap. It, too, is a mixin:</p>
218
+
219
+ <pre class="ruby"><span class="ruby-identifier">include</span> <span class="ruby-constant">CLIUtils</span><span class="ruby-operator">::</span><span class="ruby-constant">Messenging</span>
220
+ </pre>
221
+
222
+ <p>Once mixed in, you get access to <code>messenger</code>, a type of <a
223
+ href="Logger.html">Logger</a> that uses PrettyIO to send nicely-formatted
224
+ messages to your user. For example, if you&#39;d like to warn your user:</p>
225
+
226
+ <pre class="ruby"><span class="ruby-identifier">messenger</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-string">&#39;Hey pal, you need to be careful.&#39;</span>)
227
+ </pre>
228
+
229
+ <p><img
230
+ src="https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/messenger-warn.png"></p>
231
+
232
+ <h3 id="label-Messenging+Methods">Messenging Methods<span><a href="#label-Messenging+Methods">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
233
+
234
+ <p><code>messenger</code> gives you access to several basic methods:</p>
235
+ <ul><li>
236
+ <p><code>messenger.error</code>: used to show a formatted-red error message.</p>
237
+ </li><li>
238
+ <p><code>messenger.info</code>: used to show a formatted-blue infomational
239
+ message.</p>
240
+ </li><li>
241
+ <p><code>messenger.section</code>: used to show a formatted-purple sectional
242
+ message.</p>
243
+ </li><li>
244
+ <p><code>messenger.success</code>: used to show a formatted-green success
245
+ message.</p>
246
+ </li><li>
247
+ <p><code>messenger.yellow</code>: used to show a formatted-yellow warning
248
+ message.</p>
249
+ </li></ul>
250
+
251
+ <p>Let&#39;s see an example that uses them all:</p>
252
+
253
+ <pre>messenger.section(&#39;STARTING ATTACK RUN...&#39;)
254
+ messenger.info(&#39;Beginning strafing run...&#39;)
255
+ messenger.warn(&#39;WARNING: Tie Fighters approaching!&#39;)
256
+ messenger.error(&#39;Porkins died :(&#39;)
257
+ messenger.success(&#39;But Luke still blew up the Death Star!&#39;)</pre>
258
+
259
+ <p><img
260
+ src="https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/messenger-types-1.png"></p>
261
+
262
+ <p><code>messenger</code> also includes two “block” methods that allow you to
263
+ wrap program execution in messages that are “longer-term”.</p>
264
+
265
+ <pre>messenger.info_block(&#39;Starting up...&#39;, &#39;Done!&#39;, multiline = false) { # do stuff here }</pre>
266
+
267
+ <p><code>messenger</code> outputs &#39;Starting up…&#39;, runs the code in
268
+ <code># do stuff here</code>, and once complete, outputs &#39;Done!&#39; on
269
+ the same line. Note that <code>section_block</code> is the same exact
270
+ signature (except for the method name, of course!).</p>
271
+
272
+ <h3 id="label-Message+Wrapping">Message Wrapping<span><a href="#label-Message+Wrapping">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
273
+
274
+ <p>PrettyIO also gives <code>messenger</code> the ability to wrap your
275
+ messages so that they don&#39;t span off into infinity. You can even
276
+ control what the wrap limit (in characters) is:</p>
277
+
278
+ <pre>CLIUtils::PrettyIO::wrap_at(50)
279
+ messenger.info(&#39;This is a really long message, okay? It should wrap at some point. Seriously. Wrapping is nice.&#39;)
280
+ puts &#39;&#39;
281
+ CLIUtils::PrettyIO::wrap_at(20)
282
+ messenger.info(&#39;This is a really long message, okay? It should wrap at some point. Seriously. Wrapping is nice.&#39;)
283
+ puts &#39;&#39;
284
+ CLIUtils::PrettyIO::wrap(false)
285
+ messenger.info(&#39;This is a really long message, okay? It should wrap at some point. Seriously. Wrapping is nice.&#39;)</pre>
286
+
287
+ <p><img
288
+ src="https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/wrapping.png"></p>
289
+
290
+ <h3 id="label-Prompting">Prompting<span><a href="#label-Prompting">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
291
+
292
+ <p><code>messenger</code> also carries a convenient method to prompt your
293
+ users to give input (including an optional default). It makes use of
294
+ <code>readline</code>, so you can do cool things like text expansion of
295
+ paths.</p>
296
+
297
+ <pre>p = messenger.prompt(&#39;Are you a fan of Battlestar Galactica?&#39;, default = &#39;Y&#39;)
298
+ messenger.info(&quot;You answered: #{ p }&quot;)</pre>
299
+
300
+ <p><img
301
+ src="https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/prompting.png"></p>
302
+
303
+ <h3 id="label-Logging">Logging<span><a href="#label-Logging">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
304
+
305
+ <p>Often, it&#39;s desirable to log messages as they appear to your user.
306
+ <code>messenging</code> makes this a breeze by allowing you to attach and
307
+ detach <a href="Logger.html">Logger</a> instances at will.</p>
308
+
309
+ <p>For instance, let&#39;s say you wanted to log a few messages to both your
310
+ user&#39;s STDOUT and to <code>file.txt</code>:</p>
311
+
312
+ <pre>file_logger = Logger.new(&#39;file.txt&#39;)
313
+
314
+ messenger.info(&#39;This should only appear in STDOUT.&#39;)
315
+
316
+ messenger.attach(file_logger)
317
+
318
+ messenger.warn(&#39;This warning should appear in STDOUT and file.txt&#39;)
319
+ messenger.error(&#39;This error should appear in STDOUT and file.txt&#39;)
320
+ messenger.debug(&#39;This debug message should only appear in file.txt&#39;)
321
+
322
+ messenger.detach(file_logger)
323
+
324
+ messenger.section(&#39;This section message should appear only in STDOUT&#39;)</pre>
325
+
326
+ <p>In STDOUT:</p>
327
+
328
+ <p><img
329
+ src="https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/multi-logger.png"></p>
330
+
331
+ <p>…and in <code>file.txt</code>:</p>
332
+
333
+ <pre>W, [2014-03-29T15:14:34.844406 #4497] WARN -- : This warning should appear in STDOUT and file.txt
334
+ E, [2014-03-29T15:14:34.844553 #4497] ERROR -- : This error should appear in STDOUT and file.txt
335
+ D, [2014-03-29T15:14:34.844609 #4497] DEBUG -- : This debug message should only appear in file.txt</pre>
336
+
337
+ <p>Since you can attach <a href="Logger.html">Logger</a> objects, each can
338
+ have it&#39;s own format and severity level. Cool!</p>
339
+
340
+ <h2 id="label-Configuration">Configuration<span><a href="#label-Configuration">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
341
+
342
+ <p><a href="CLIUtils.html">CLIUtils</a> offers two “things” – a
343
+ <code>Configurator</code> class and a <code>Configuration</code> module
344
+ that provides access to a shared instance of <code>Configurator</code> –
345
+ that make managing a user&#39;s configuration parameters easy. Mix it in!</p>
346
+
347
+ <pre>include CLIUtils::Configuration</pre>
348
+
349
+ <h3 id="label-Loading+a+Configuration+File">Loading a Configuration File<span><a href="#label-Loading+a+Configuration+File">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
350
+
351
+ <pre>load_configuration(&#39;~/.my-app-config&#39;)</pre>
352
+
353
+ <p>If there&#39;s data in there, it will be consumed into
354
+ <code>configuration</code>&#39;s <code>data</code> property.</p>
355
+
356
+ <h3 id="label-Adding%2FRemoving+Sections">Adding/Removing Sections<span><a href="#label-Adding%2FRemoving+Sections">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
357
+
358
+ <p>Sections are top levels of the configuration file and are managed via the
359
+ <code>configuration</code> object:</p>
360
+
361
+ <pre>configuration.add_section(:user_data)
362
+ configuration.add_section(:program_data)
363
+ configuration.delete_section(:program_data)</pre>
364
+
365
+ <h3 id="label-Adding+Data+to+Sections">Adding Data to Sections<span><a href="#label-Adding+Data+to+Sections">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
366
+
367
+ <p>There are two ways data can be managed in <code>configuration</code>: via
368
+ its <code>@data</code> property or via some magic methods; your call:</p>
369
+
370
+ <pre>configuration.data[:user_data].merge!(username: &#39;bob&#39;)
371
+ # OR
372
+ configuration.user_data.merge!(username: &#39;bob&#39;)</pre>
373
+
374
+ <h3 id="label-Saving+to+a+File">Saving to a File<span><a href="#label-Saving+to+a+File">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
375
+
376
+ <p>When you&#39;re ready to save your configuration data to a YAML file:</p>
377
+
378
+ <pre>configuration.save</pre>
379
+
380
+ <p>Note that all your keys are converted to strings before saving (and,
381
+ likewise, are converted to symbols, when loading). Assuming we used the
382
+ commands above, we could expect this to be the contents of
383
+ <code>~/.my-app-config</code>:</p>
384
+
385
+ <pre>---
386
+ user_data:
387
+ username: bob</pre>
388
+
389
+ <h1 id="label-Known+Issues">Known Issues<span><a href="#label-Known+Issues">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
390
+ <ul><li>
391
+ <p>LoggerDelegator doesn&#39;t currently know what to do with
392
+ <code>messenger.prompt</code>, so you&#39;ll have to manually log a
393
+ <code>debug</code> message if you want that information logged.</p>
394
+ </li></ul>
395
+
396
+ <h1 id="label-Bugs+and+Feature+Requests">Bugs and Feature Requests<span><a href="#label-Bugs+and+Feature+Requests">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
397
+
398
+ <p>To report bugs with or suggest features/changes for <a
399
+ href="CLIUtils.html">CLIUtils</a>, please use the <a
400
+ href="http://github.com/bachya/cli-utils/issues">Issues Page</a>.</p>
401
+
402
+ <h1 id="label-Contributing">Contributing<span><a href="#label-Contributing">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
403
+
404
+ <p>Contributions are welcome and encouraged. To contribute:</p>
405
+ <ol><li>
406
+ <p>Fork it ( <a
407
+ href="http://github.com/bachya/cliutils/fork">github.com/bachya/cliutils/fork</a>
408
+ )</p>
409
+ </li><li>
410
+ <p>Create your feature branch (<code>git checkout -b my-new-feature</code>)</p>
411
+ </li><li>
412
+ <p>Commit your changes (<code>git commit -am &#39;Add some
413
+ feature&#39;</code>)</p>
414
+ </li><li>
415
+ <p>Push to the branch (<code>git push origin my-new-feature</code>)</p>
416
+ </li><li>
417
+ <p>Create new Pull Request</p>
418
+ </li></ol>
419
+
420
+ <h1 id="label-License">License<span><a href="#label-License">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
421
+
422
+ <p>(The MIT License)</p>
423
+
424
+ <p>Copyright © 2014 Aaron Bach <a
425
+ href="mailto:bachya1208@gmail.com">bachya1208@gmail.com</a></p>
426
+
427
+ <p>Permission is hereby granted, free of charge, to any person obtaining a
428
+ copy of this software and associated documentation files (the
429
+ &#39;Software&#39;), to deal in the Software without restriction, including
430
+ without limitation the rights to use, copy, modify, merge, publish,
431
+ distribute, sublicense, and/or sell copies of the Software, and to permit
432
+ persons to whom the Software is furnished to do so, subject to the
433
+ following conditions:</p>
434
+
435
+ <p>The above copyright notice and this permission notice shall be included in
436
+ all copies or substantial portions of the Software.</p>
437
+
438
+ <p>THE SOFTWARE IS PROVIDED &#39;AS IS&#39;, WITHOUT WARRANTY OF ANY KIND,
439
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
440
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
441
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
442
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
443
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
444
+ USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
445
+ </main>
446
+
447
+
448
+
449
+ <footer id="validator-badges" role="contentinfo">
450
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
451
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
452
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
453
+ </footer>
454
+