rbcli 0.2.12 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/Gemfile.lock +39 -38
  4. data/docs-src/content/development/changelog.md +16 -1
  5. data/docs-src/themes/hugo-theme-learn/CHANGELOG.md +74 -2
  6. data/docs-src/themes/hugo-theme-learn/README.md +42 -5
  7. data/docs-src/themes/hugo-theme-learn/exampleSite/config.toml +27 -0
  8. data/docs-src/themes/hugo-theme-learn/exampleSite/content/basics/_index.zh.md +12 -0
  9. data/docs-src/themes/hugo-theme-learn/exampleSite/content/basics/configuration/_index.en.md +6 -4
  10. data/docs-src/themes/hugo-theme-learn/exampleSite/content/basics/configuration/_index.fr.md +7 -5
  11. data/docs-src/themes/hugo-theme-learn/exampleSite/content/basics/installation/_index.en.md +1 -1
  12. data/docs-src/themes/hugo-theme-learn/exampleSite/content/cont/markdown.en.md +88 -61
  13. data/docs-src/themes/hugo-theme-learn/exampleSite/content/cont/pages/_index.fr.md +3 -3
  14. data/docs-src/themes/hugo-theme-learn/exampleSite/content/cont/syntaxhighlight.en.md +89 -0
  15. data/docs-src/themes/hugo-theme-learn/exampleSite/content/shortcodes/children/_index.en.md +2 -2
  16. data/docs-src/themes/hugo-theme-learn/exampleSite/content/shortcodes/notice.en.md +2 -2
  17. data/docs-src/themes/hugo-theme-learn/exampleSite/content/showcase.en.md +4 -1
  18. data/docs-src/themes/hugo-theme-learn/exampleSite/content/showcase.fr.md +4 -1
  19. data/docs-src/themes/hugo-theme-learn/exampleSite/static/fonts/monogramos-webfont.svg +1 -237
  20. data/docs-src/themes/hugo-theme-learn/exampleSite/static/images/showcase/inteliver_docs.png +0 -0
  21. data/docs-src/themes/hugo-theme-learn/exampleSite/static/images/showcase/tshark_dev.png +0 -0
  22. data/docs-src/themes/hugo-theme-learn/i18n/ar.toml +26 -0
  23. data/docs-src/themes/hugo-theme-learn/i18n/de.toml +26 -0
  24. data/docs-src/themes/hugo-theme-learn/i18n/hi.toml +26 -0
  25. data/docs-src/themes/hugo-theme-learn/i18n/ja.toml +26 -0
  26. data/docs-src/themes/hugo-theme-learn/i18n/ru.toml +26 -0
  27. data/docs-src/themes/hugo-theme-learn/i18n/zh-cn.toml +26 -0
  28. data/docs-src/themes/hugo-theme-learn/layouts/_default/list.html +1 -1
  29. data/docs-src/themes/hugo-theme-learn/layouts/_default/single.html +1 -2
  30. data/docs-src/themes/hugo-theme-learn/layouts/partials/footer.html +3 -4
  31. data/docs-src/themes/hugo-theme-learn/layouts/partials/header.html +8 -6
  32. data/docs-src/themes/hugo-theme-learn/layouts/partials/menu.html +6 -5
  33. data/docs-src/themes/hugo-theme-learn/layouts/shortcodes/children.html +2 -2
  34. data/docs-src/themes/hugo-theme-learn/layouts/shortcodes/ref.html +1 -1
  35. data/docs-src/themes/hugo-theme-learn/layouts/shortcodes/relref.html +1 -1
  36. data/docs-src/themes/hugo-theme-learn/netlify.toml +1 -2
  37. data/docs-src/themes/hugo-theme-learn/static/css/theme.css +4 -0
  38. data/docs-src/themes/hugo-theme-learn/static/fonts/Inconsolata.svg +1 -359
  39. data/docs-src/themes/hugo-theme-learn/static/fonts/Novecentosanswide-Normal-webfont.svg +1 -1019
  40. data/docs-src/themes/hugo-theme-learn/static/fonts/Novecentosanswide-UltraLight-webfont.svg +1 -918
  41. data/docs-src/themes/hugo-theme-learn/static/fonts/Work_Sans_200.svg +1 -332
  42. data/docs-src/themes/hugo-theme-learn/static/fonts/Work_Sans_300.svg +1 -331
  43. data/docs-src/themes/hugo-theme-learn/static/fonts/Work_Sans_500.svg +1 -333
  44. data/docs-src/themes/hugo-theme-learn/static/images/clippy.svg +1 -1
  45. data/docs-src/themes/hugo-theme-learn/static/js/auto-complete.js +3 -223
  46. data/docs-src/themes/hugo-theme-learn/static/js/highlight.pack.js +6 -3
  47. data/docs-src/themes/hugo-theme-learn/static/js/hugo-learn.js +8 -5
  48. data/docs-src/themes/hugo-theme-learn/static/webfonts/fa-brands-400.svg +1 -1260
  49. data/docs-src/themes/hugo-theme-learn/static/webfonts/fa-regular-400.svg +1 -471
  50. data/docs-src/themes/hugo-theme-learn/static/webfonts/fa-solid-900.svg +1 -2763
  51. data/docs/404.html +8 -8
  52. data/docs/advanced/automatic_updates/index.html +85 -65
  53. data/docs/advanced/command_types/index.html +139 -144
  54. data/docs/advanced/distributed_state_locking/index.html +83 -55
  55. data/docs/advanced/hooks/index.html +94 -81
  56. data/docs/advanced/index.html +75 -34
  57. data/docs/advanced/index.xml +8 -8
  58. data/docs/advanced/interactive_commands/index.html +90 -66
  59. data/docs/advanced/logging/index.html +94 -67
  60. data/docs/advanced/remote_execution/index.html +94 -75
  61. data/docs/advanced/state_storage/index.html +122 -119
  62. data/docs/advanced/user_config_files/index.html +94 -71
  63. data/docs/categories/index.html +82 -30
  64. data/docs/categories/index.xml +1 -1
  65. data/docs/css/theme.css +4 -0
  66. data/docs/development/changelog/index.html +185 -177
  67. data/docs/development/code_of_conduct/index.html +85 -64
  68. data/docs/development/contributing/index.html +96 -96
  69. data/docs/development/index.html +75 -34
  70. data/docs/development/index.xml +2 -2
  71. data/docs/development/license/index.html +80 -46
  72. data/docs/fonts/Inconsolata.svg +1 -359
  73. data/docs/fonts/Novecentosanswide-Normal-webfont.svg +1 -1019
  74. data/docs/fonts/Novecentosanswide-UltraLight-webfont.svg +1 -918
  75. data/docs/fonts/Work_Sans_200.svg +1 -332
  76. data/docs/fonts/Work_Sans_300.svg +1 -331
  77. data/docs/fonts/Work_Sans_500.svg +1 -333
  78. data/docs/images/clippy.svg +1 -1
  79. data/docs/index.html +112 -61
  80. data/docs/index.json +24 -24
  81. data/docs/index.xml +13 -13
  82. data/docs/js/auto-complete.js +3 -223
  83. data/docs/js/highlight.pack.js +6 -3
  84. data/docs/js/hugo-learn.js +8 -5
  85. data/docs/quick_reference/index.html +126 -159
  86. data/docs/quick_reference/index.xml +1 -1
  87. data/docs/sitemap.xml +2 -4
  88. data/docs/tags/index.html +82 -30
  89. data/docs/tags/index.xml +1 -1
  90. data/docs/tutorial/10-getting_started/index.html +87 -66
  91. data/docs/tutorial/20-project_layout/index.html +126 -116
  92. data/docs/tutorial/30-your_first_command/index.html +151 -141
  93. data/docs/tutorial/40-options_parameters_and_arguments/index.html +233 -258
  94. data/docs/tutorial/50-publishing/index.html +86 -66
  95. data/docs/tutorial/index.html +75 -34
  96. data/docs/tutorial/index.xml +4 -4
  97. data/docs/webfonts/fa-brands-400.svg +1 -1260
  98. data/docs/webfonts/fa-regular-400.svg +1 -471
  99. data/docs/webfonts/fa-solid-900.svg +1 -2763
  100. data/docs/whoami/index.html +76 -46
  101. data/docs/whoami/index.xml +1 -1
  102. data/lib/rbcli/configuration/configurate_blocks/me.rb +5 -5
  103. data/lib/rbcli/util/deprecation_warning.rb +21 -4
  104. data/lib/rbcli/version.rb +1 -1
  105. data/rbcli.gemspec +8 -8
  106. data/skeletons/project/Gemfile +1 -1
  107. data/skeletons/project/config/general.rb +1 -1
  108. data/skeletons/project/lib/lib.erb +2 -0
  109. data/skeletons/project/spec/spec_helper.rb +7 -7
  110. data/skeletons/project/spec/untitled_spec.rb +6 -6
  111. data/skeletons/project/untitled.gemspec +28 -26
  112. metadata +29 -20
  113. data/docs-src/themes/hugo-theme-learn/static/js/html5shiv-printshiv.min.js +0 -4
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <meta name="generator" content="Hugo 0.55.6" />
6
+ <meta name="generator" content="Hugo 0.74.3" />
7
7
  <meta name="description" content="">
8
8
 
9
9
 
@@ -12,20 +12,21 @@
12
12
  <title>Your First Command :: RBCli Documentation</title>
13
13
 
14
14
 
15
- <link href="/rbcli/css/nucleus.css?1561087612" rel="stylesheet">
16
- <link href="/rbcli/css/fontawesome-all.min.css?1561087612" rel="stylesheet">
17
- <link href="/rbcli/css/hybrid.css?1561087612" rel="stylesheet">
18
- <link href="/rbcli/css/featherlight.min.css?1561087612" rel="stylesheet">
19
- <link href="/rbcli/css/perfect-scrollbar.min.css?1561087612" rel="stylesheet">
20
- <link href="/rbcli/css/auto-complete.css?1561087612" rel="stylesheet">
21
- <link href="/rbcli/css/atom-one-dark-reasonable.css?1561087612" rel="stylesheet">
22
- <link href="/rbcli/css/theme.css?1561087612" rel="stylesheet">
23
- <link href="/rbcli/css/hugo-theme.css?1561087612" rel="stylesheet">
15
+ <link href="/rbcli/css/nucleus.css?1596148729" rel="stylesheet">
16
+ <link href="/rbcli/css/fontawesome-all.min.css?1596148729" rel="stylesheet">
17
+ <link href="/rbcli/css/hybrid.css?1596148729" rel="stylesheet">
18
+ <link href="/rbcli/css/featherlight.min.css?1596148729" rel="stylesheet">
19
+ <link href="/rbcli/css/perfect-scrollbar.min.css?1596148729" rel="stylesheet">
20
+ <link href="/rbcli/css/auto-complete.css?1596148729" rel="stylesheet">
21
+ <link href="/rbcli/css/atom-one-dark-reasonable.css?1596148729" rel="stylesheet">
22
+ <link href="/rbcli/css/theme.css?1596148729" rel="stylesheet">
23
+ <link href="/rbcli/css/hugo-theme.css?1596148729" rel="stylesheet">
24
+
25
+ <link href="/rbcli/css/theme-blue.css?1596148729" rel="stylesheet">
24
26
 
25
- <link href="/rbcli/css/theme-blue.css?1561087612" rel="stylesheet">
26
27
 
27
28
 
28
- <script src="/rbcli/js/jquery-3.3.1.min.js?1561087612"></script>
29
+ <script src="/rbcli/js/jquery-3.3.1.min.js?1596148729"></script>
29
30
 
30
31
  <style>
31
32
  :root #header + #content > #left > #rlblock_left{
@@ -54,14 +55,14 @@
54
55
  <span data-search-clear=""><i class="fas fa-times"></i></span>
55
56
  </div>
56
57
 
57
- <script type="text/javascript" src="/rbcli/js/lunr.min.js?1561087612"></script>
58
- <script type="text/javascript" src="/rbcli/js/auto-complete.js?1561087612"></script>
58
+ <script type="text/javascript" src="/rbcli/js/lunr.min.js?1596148729"></script>
59
+ <script type="text/javascript" src="/rbcli/js/auto-complete.js?1596148729"></script>
59
60
  <script type="text/javascript">
60
61
 
61
62
  var baseurl = "https:\/\/akhoury6.github.io\/rbcli\/";
62
63
 
63
64
  </script>
64
- <script type="text/javascript" src="/rbcli/js/search.js?1561087612"></script>
65
+ <script type="text/javascript" src="/rbcli/js/search.js?1596148729"></script>
65
66
 
66
67
 
67
68
  </div>
@@ -74,6 +75,8 @@
74
75
 
75
76
 
76
77
 
78
+
79
+
77
80
 
78
81
 
79
82
 
@@ -96,6 +99,8 @@
96
99
 
97
100
 
98
101
 
102
+
103
+
99
104
 
100
105
 
101
106
 
@@ -121,6 +126,8 @@
121
126
 
122
127
 
123
128
 
129
+
130
+
124
131
 
125
132
 
126
133
 
@@ -140,6 +147,8 @@
140
147
 
141
148
 
142
149
 
150
+
151
+
143
152
 
144
153
 
145
154
 
@@ -159,6 +168,8 @@
159
168
 
160
169
 
161
170
 
171
+
172
+
162
173
 
163
174
 
164
175
 
@@ -178,6 +189,8 @@
178
189
 
179
190
 
180
191
 
192
+
193
+
181
194
 
182
195
 
183
196
 
@@ -197,6 +210,8 @@
197
210
 
198
211
 
199
212
 
213
+
214
+
200
215
 
201
216
 
202
217
 
@@ -223,6 +238,8 @@
223
238
 
224
239
 
225
240
 
241
+
242
+
226
243
 
227
244
 
228
245
 
@@ -248,6 +265,8 @@
248
265
 
249
266
 
250
267
 
268
+
269
+
251
270
 
252
271
 
253
272
 
@@ -267,6 +286,8 @@
267
286
 
268
287
 
269
288
 
289
+
290
+
270
291
 
271
292
 
272
293
 
@@ -286,6 +307,8 @@
286
307
 
287
308
 
288
309
 
310
+
311
+
289
312
 
290
313
 
291
314
 
@@ -305,6 +328,8 @@
305
328
 
306
329
 
307
330
 
331
+
332
+
308
333
 
309
334
 
310
335
 
@@ -324,6 +349,8 @@
324
349
 
325
350
 
326
351
 
352
+
353
+
327
354
 
328
355
 
329
356
 
@@ -343,6 +370,8 @@
343
370
 
344
371
 
345
372
 
373
+
374
+
346
375
 
347
376
 
348
377
 
@@ -362,6 +391,8 @@
362
391
 
363
392
 
364
393
 
394
+
395
+
365
396
 
366
397
 
367
398
 
@@ -381,6 +412,8 @@
381
412
 
382
413
 
383
414
 
415
+
416
+
384
417
 
385
418
 
386
419
 
@@ -400,6 +433,8 @@
400
433
 
401
434
 
402
435
 
436
+
437
+
403
438
 
404
439
 
405
440
 
@@ -426,6 +461,8 @@
426
461
 
427
462
 
428
463
 
464
+
465
+
429
466
 
430
467
 
431
468
 
@@ -451,6 +488,8 @@
451
488
 
452
489
 
453
490
 
491
+
492
+
454
493
 
455
494
 
456
495
 
@@ -470,6 +509,8 @@
470
509
 
471
510
 
472
511
 
512
+
513
+
473
514
 
474
515
 
475
516
 
@@ -489,6 +530,8 @@
489
530
 
490
531
 
491
532
 
533
+
534
+
492
535
 
493
536
 
494
537
 
@@ -508,6 +551,8 @@
508
551
 
509
552
 
510
553
 
554
+
555
+
511
556
 
512
557
 
513
558
 
@@ -534,6 +579,8 @@
534
579
 
535
580
 
536
581
 
582
+
583
+
537
584
 
538
585
 
539
586
 
@@ -585,7 +632,6 @@
585
632
 
586
633
 
587
634
 
588
-
589
635
  <section id="body">
590
636
  <div id="overlay"></div>
591
637
  <div class="padding highlightable">
@@ -619,9 +665,9 @@
619
665
 
620
666
  <a href='/rbcli/'></a> > <a href='/rbcli/tutorial/'>Tutorial</a> > Your First Command
621
667
 
622
-
668
+
623
669
 
624
-
670
+
625
671
 
626
672
 
627
673
 
@@ -631,15 +677,12 @@
631
677
  <div class="progress">
632
678
  <div class="wrapper">
633
679
  <nav id="TableOfContents">
634
- <ul>
635
- <li>
636
- <ul>
637
- <li><a href="#creating-the-command">Creating the Command</a></li>
638
- <li><a href="#the-command-declaration">The Command Declaration</a></li>
639
- <li><a href="#creating-the-list-command">Creating the &ldquo;list&rdquo; Command</a></li>
640
- <li><a href="#next-steps">Next Steps</a></li>
641
- </ul></li>
642
- </ul>
680
+ <ul>
681
+ <li><a href="#creating-the-command">Creating the Command</a></li>
682
+ <li><a href="#the-command-declaration">The Command Declaration</a></li>
683
+ <li><a href="#creating-the-list-command">Creating the &ldquo;list&rdquo; Command</a></li>
684
+ <li><a href="#next-steps">Next Steps</a></li>
685
+ </ul>
643
686
  </nav>
644
687
  </div>
645
688
  </div>
@@ -663,145 +706,113 @@
663
706
 
664
707
 
665
708
 
666
-
667
-
668
-
669
709
  <h2 id="creating-the-command">Creating the Command</h2>
670
-
671
710
  <p>Creating the command is straightforward:</p>
672
-
673
- <pre><code class="language-bash">rbcli command --name=list
674
- #or
711
+ <div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">rbcli command --name<span style="color:#f92672">=</span>list
712
+ <span style="color:#75715e">#or</span>
675
713
  rbcli command -n list
676
- </code></pre>
677
-
678
- <p>And there you have it! Now you can try out your command by typing:</p>
679
-
680
- <pre><code class="language-bash">./exe/mytool list
681
- </code></pre>
682
-
683
- <p>Congrats! You should now see a generic output listing the values of several variables. We&rsquo;ll get into what they mean in a bit, but first, let&rsquo;s make the tool&rsquo;s execution a bit easier.</p>
684
-
714
+ </code></pre></div><p>And there you have it! Now you can try out your command by typing:</p>
715
+ <div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">./exe/mytool list
716
+ </code></pre></div><p>Congrats! You should now see a generic output listing the values of several variables. We&rsquo;ll get into what they mean in a bit, but first, let&rsquo;s make the tool&rsquo;s execution a bit easier.</p>
685
717
  <p>Now that you know your way around a project, its time to create your first command! But before we do, let&rsquo;s make development just a little bit easier. Go to the base directory of the folder and type:</p>
686
-
687
- <pre><code class="language-bash">alias mytool=&quot;$(pwd)/exe/mytool&quot;
688
- </code></pre>
689
-
690
- <p>And now you&rsquo;ll be able to execute your application as if it was already installed as a gem, without worrying about the working path. You can see this in action by running your application again, but without the path:</p>
691
-
692
- <pre><code class="language-bash">mytool list
693
- </code></pre>
694
-
695
- <p>So, now let&rsquo;s take a more in-dpeth look at what the command code looks like.</p>
696
-
718
+ <div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">alias mytool<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;</span><span style="color:#66d9ef">$(</span>pwd<span style="color:#66d9ef">)</span><span style="color:#e6db74">/exe/mytool&#34;</span>
719
+ </code></pre></div><p>And now you&rsquo;ll be able to execute your application as if it was already installed as a gem, without worrying about the working path. You can see this in action by running your application again, but without the path:</p>
720
+ <div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">mytool list
721
+ </code></pre></div><p>So, now let&rsquo;s take a more in-dpeth look at what the command code looks like.</p>
697
722
  <h2 id="the-command-declaration">The Command Declaration</h2>
698
-
699
723
  <p>As mentioned in the previous section, you can find your commands listed under the <code>application/commands/</code> directory. Each command will appear as its own unique file with some base code to work from. Let&rsquo;s take a look at that code a little more in-depth:</p>
700
-
701
- <pre><code class="language-ruby">class List &lt; Rbcli::Command # Declare a new command by subclassing Rbcli::Command
702
- description 'TODO: Description goes here' # (Required) Short description for the global help
703
- usage &lt;&lt;-EOF
704
- TODO: Usage text goes here
705
- EOF # (Required) Long description for the command-specific help
706
- parameter :force, 'Force testing', type: :boolean, default: false, required: false # (Optional, Multiple) Add a command-specific CLI parameter. Can be called multiple times
707
-
708
- config_default :myopt2, description: 'My Option #2', default: 'Default Value Here' # (Optional, Multiple) Specify an individual configuration parameter and set a default value. These will also be included in generated user config.
709
- # Alternatively, you can simply create a yaml file in the `default_user_configs` directory in your project that specifies the default values of all options
710
-
711
- action do |params, args, global_opts, config| # (Required) Block to execute if the command is called.
712
- Rbcli::log.info { 'These logs can go to STDERR, STDOUT, or a file' } # Example log. Interface is identical to Ruby's logger
713
- puts &quot;\nArgs:\n#{args}&quot; # Arguments that came after the command on the CLI (i.e.: `mytool test bar baz` will yield args=['bar', 'baz'])
714
- puts &quot;Params:\n#{params}&quot; # Parameters, as described through the option statements above
715
- puts &quot;Global opts:\n#{global_opts}&quot; # Global Parameters, as descirbed in the Configurate section
716
- puts &quot;Config:\n#{config}&quot; # Config file values
717
- puts &quot;LocalState:\n#{Rbcli.local_state}&quot; # Local persistent state storage (when available) -- if unsure use Rbcli.local_state.nil?
718
- puts &quot;RemoteState:\n#{Rbcli.remote_state}&quot; # Remote persistent state storage (when available) -- if unsure use Rbcli.remote_state.nil?
719
- puts &quot;\nDone!!!&quot;
720
- end
721
- end
722
- </code></pre>
723
-
724
- <p>Commands are declared to RBCli simply by subclassing them from <code>Rbcli::Command</code> as shown above. Then, you have a list of declarations that tell RBCli information about it. They are:</p>
725
-
724
+ <div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-ruby" data-lang="ruby"><span style="color:#66d9ef">class</span> <span style="color:#a6e22e">List</span> <span style="color:#f92672">&lt;</span> <span style="color:#66d9ef">Rbcli</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Command</span> <span style="color:#75715e"># Declare a new command by subclassing Rbcli::Command</span>
725
+ description <span style="color:#e6db74">&#39;TODO: Description goes here&#39;</span> <span style="color:#75715e"># (Required) Short description for the global help</span>
726
+ usage <span style="color:#e6db74">&lt;&lt;-EOF
727
+ </span><span style="color:#e6db74"></span><span style="color:#e6db74">TODO</span>: <span style="color:#66d9ef">Usage</span> text goes here
728
+ <span style="color:#66d9ef">EOF</span> <span style="color:#75715e"># (Required) Long description for the command-specific help</span>
729
+ parameter <span style="color:#e6db74">:force</span>, <span style="color:#e6db74">&#39;Force testing&#39;</span>, <span style="color:#e6db74">type</span>: <span style="color:#e6db74">:boolean</span>, <span style="color:#e6db74">default</span>: <span style="color:#66d9ef">false</span>, <span style="color:#e6db74">required</span>: <span style="color:#66d9ef">false</span> <span style="color:#75715e"># (Optional, Multiple) Add a command-specific CLI parameter. Can be called multiple times</span>
730
+
731
+ config_default <span style="color:#e6db74">:myopt2</span>, <span style="color:#e6db74">description</span>: <span style="color:#e6db74">&#39;My Option #2&#39;</span>, <span style="color:#e6db74">default</span>: <span style="color:#e6db74">&#39;Default Value Here&#39;</span> <span style="color:#75715e"># (Optional, Multiple) Specify an individual configuration parameter and set a default value. These will also be included in generated user config.</span>
732
+ <span style="color:#75715e"># Alternatively, you can simply create a yaml file in the `default_user_configs` directory in your project that specifies the default values of all options</span>
733
+
734
+ action <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>params, args, global_opts, config<span style="color:#f92672">|</span> <span style="color:#75715e"># (Required) Block to execute if the command is called.</span>
735
+ <span style="color:#66d9ef">Rbcli</span><span style="color:#f92672">::</span>log<span style="color:#f92672">.</span>info { <span style="color:#e6db74">&#39;These logs can go to STDERR, STDOUT, or a file&#39;</span> } <span style="color:#75715e"># Example log. Interface is identical to Ruby&#39;s logger</span>
736
+ puts <span style="color:#e6db74">&#34;</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">Args:</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">#{</span>args<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span> <span style="color:#75715e"># Arguments that came after the command on the CLI (i.e.: `mytool test bar baz` will yield args=[&#39;bar&#39;, &#39;baz&#39;])</span>
737
+ puts <span style="color:#e6db74">&#34;Params:</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">#{</span>params<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span> <span style="color:#75715e"># Parameters, as described through the option statements above</span>
738
+ puts <span style="color:#e6db74">&#34;Global opts:</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">#{</span>global_opts<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span> <span style="color:#75715e"># Global Parameters, as descirbed in the Configurate section</span>
739
+ puts <span style="color:#e6db74">&#34;Config:</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">#{</span>config<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span> <span style="color:#75715e"># Config file values</span>
740
+ puts <span style="color:#e6db74">&#34;LocalState:</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">#{</span><span style="color:#66d9ef">Rbcli</span><span style="color:#f92672">.</span>local_state<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span> <span style="color:#75715e"># Local persistent state storage (when available) -- if unsure use Rbcli.local_state.nil?</span>
741
+ puts <span style="color:#e6db74">&#34;RemoteState:</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">#{</span><span style="color:#66d9ef">Rbcli</span><span style="color:#f92672">.</span>remote_state<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span> <span style="color:#75715e"># Remote persistent state storage (when available) -- if unsure use Rbcli.remote_state.nil?</span>
742
+ puts <span style="color:#e6db74">&#34;</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">Done!!!&#34;</span>
743
+ <span style="color:#66d9ef">end</span>
744
+ <span style="color:#66d9ef">end</span>
745
+ </code></pre></div><p>Commands are declared to RBCli simply by subclassing them from <code>Rbcli::Command</code> as shown above. Then, you have a list of declarations that tell RBCli information about it. They are:</p>
726
746
  <ul>
727
747
  <li><code>description</code>
728
-
729
748
  <ul>
730
749
  <li>A short description of the command, which will appear in the top-level help (when the user runs <code>mytool -h</code>).</li>
731
- </ul></li>
750
+ </ul>
751
+ </li>
732
752
  <li><code>usage</code>
733
-
734
753
  <ul>
735
754
  <li>A description of how the command is meant to be used. This description can be as long as you want, and can be as in-depth as you&rsquo;d like. It will show up as a long, multi-line description when the user runs the command-sepcific help (<code>mytool list -h</code>).</li>
736
- </ul></li>
755
+ </ul>
756
+ </li>
737
757
  <li><code>parameter</code>
738
-
739
758
  <ul>
740
759
  <li>Command-line tags that the user can enter that are specific to only this command. We will get into these in the next section on <a href="/rbcli/tutorial/40-options_parameters_and_arguments/">Options, Parameters, and Arguments</a></li>
741
- </ul></li>
760
+ </ul>
761
+ </li>
742
762
  <li><code>config_default</code>
743
-
744
763
  <ul>
745
764
  <li>This sets a single item in the config file that will be made available to the user. More information can be found in the documentation on <a href="/rbcli/advanced/user_config_files/">User Config Files</a></li>
746
- </ul></li>
765
+ </ul>
766
+ </li>
747
767
  <li><code>action</code>
748
-
749
768
  <ul>
750
769
  <li>This loads the block of code that will run when the command is called. It brings in all of the CLI and user config data as variables. We will also get into these in the next section <a href="/rbcli/tutorial/40-options_parameters_and_arguments/">Options, Parameters, and Arguments</a></li>
751
- </ul></li>
752
770
  </ul>
753
-
771
+ </li>
772
+ </ul>
754
773
  <p>There is an additional declaration not shown here, <code>extern</code>. You can find more information on it in the section on <a href="/rbcli/advanced/command_types/">Advanced Command Types</a></p>
755
-
756
774
  <h2 id="creating-the-list-command">Creating the &ldquo;list&rdquo; Command</h2>
757
-
758
775
  <p>Now we&rsquo;re going to modify this command to list the contents of the current directory to the terminal. So let&rsquo;s change the code in that file to:</p>
759
-
760
- <pre><code class="language-ruby">class List &lt; Rbcli::Command
761
- description %q{List files in current directory}
762
- usage &lt;&lt;-EOF
763
- Ever wanted to see your files?
764
- Now you can!
765
- EOF
766
-
767
- action do |params, args, global_opts, config|
768
- filelist = []
769
-
770
- # We store a list of the files in an array, including dotfiles if specified
771
- Dir.glob &quot;./*&quot; do |filename|
772
- outname = filename.split('/')[1]
773
- outname += '/' if File.directory? filename
774
- filelist.append outname
775
- end
776
+ <div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-ruby" data-lang="ruby"><span style="color:#66d9ef">class</span> <span style="color:#a6e22e">List</span> <span style="color:#f92672">&lt;</span> <span style="color:#66d9ef">Rbcli</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Command</span>
777
+ description <span style="color:#e6db74">%q{List files in current directory}</span>
778
+ usage <span style="color:#e6db74">&lt;&lt;-EOF
779
+ </span><span style="color:#e6db74"></span><span style="color:#66d9ef">Ever</span> wanted to see your files?
780
+ <span style="color:#66d9ef">Now</span> you can!
781
+ <span style="color:#66d9ef">EOF</span>
782
+
783
+ action <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>params, args, global_opts, config<span style="color:#f92672">|</span>
784
+ filelist <span style="color:#f92672">=</span> <span style="color:#f92672">[]</span>
785
+
786
+ <span style="color:#75715e"># We store a list of the files in an array, including dotfiles if specified</span>
787
+ <span style="color:#66d9ef">Dir</span><span style="color:#f92672">.</span>glob <span style="color:#e6db74">&#34;./*&#34;</span> <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>filename<span style="color:#f92672">|</span>
788
+ outname <span style="color:#f92672">=</span> filename<span style="color:#f92672">.</span>split(<span style="color:#e6db74">&#39;/&#39;</span>)<span style="color:#f92672">[</span><span style="color:#ae81ff">1</span><span style="color:#f92672">]</span>
789
+ outname <span style="color:#f92672">+=</span> <span style="color:#e6db74">&#39;/&#39;</span> <span style="color:#66d9ef">if</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>directory? filename
790
+ filelist<span style="color:#f92672">.</span>append outname
791
+ <span style="color:#66d9ef">end</span>
776
792
 
777
- # Apply color
778
- filelist.map! do |filename|
779
- if File.directory? filename
780
- filename.light_blue
781
- elsif File.executable? filename
782
- filename.light_green
783
- else
793
+ <span style="color:#75715e"># Apply color</span>
794
+ filelist<span style="color:#f92672">.</span>map! <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>filename<span style="color:#f92672">|</span>
795
+ <span style="color:#66d9ef">if</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>directory? filename
796
+ filename<span style="color:#f92672">.</span>light_blue
797
+ <span style="color:#66d9ef">elsif</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>executable? filename
798
+ filename<span style="color:#f92672">.</span>light_green
799
+ <span style="color:#66d9ef">else</span>
784
800
  filename
785
- end
786
- end if global_opts[:color]
801
+ <span style="color:#66d9ef">end</span>
802
+ <span style="color:#66d9ef">end</span> <span style="color:#66d9ef">if</span> global_opts<span style="color:#f92672">[</span><span style="color:#e6db74">:color</span><span style="color:#f92672">]</span>
787
803
 
788
804
  puts filelist
789
- end
790
- end
791
- </code></pre>
792
-
793
- <p>Go ahead and test it out! The output doesn&rsquo;t show much obviously, just a list of names and nothing else. Don&rsquo;t worry though, we&rsquo;ll fix that in the next secion.</p>
794
-
805
+ <span style="color:#66d9ef">end</span>
806
+ <span style="color:#66d9ef">end</span>
807
+ </code></pre></div><p>Go ahead and test it out! The output doesn&rsquo;t show much obviously, just a list of names and nothing else. Don&rsquo;t worry though, we&rsquo;ll fix that in the next secion.</p>
795
808
  <h2 id="next-steps">Next Steps</h2>
796
-
797
809
  <p>Next we&rsquo;re going to take a look at options, parameters, and arguments, and we&rsquo;ll clean up our list command by using them. If you&rsquo;d like to learn more about the additional command types in RBCli before continuing, see the <a href="/rbcli/advanced/command_types/">Advanced Command Types</a> documentation.</p>
798
810
 
799
811
 
800
- <footer class=" footline" >
812
+ <footer class="footline">
801
813
 
802
814
  </footer>
803
815
 
804
-
805
816
 
806
817
  </div>
807
818
 
@@ -1229,20 +1240,19 @@ end
1229
1240
  <div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
1230
1241
  <div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
1231
1242
  </div>
1232
- <script src="/rbcli/js/clipboard.min.js?1561087612"></script>
1233
- <script src="/rbcli/js/perfect-scrollbar.min.js?1561087612"></script>
1234
- <script src="/rbcli/js/perfect-scrollbar.jquery.min.js?1561087612"></script>
1235
- <script src="/rbcli/js/jquery.sticky.js?1561087612"></script>
1236
- <script src="/rbcli/js/featherlight.min.js?1561087612"></script>
1237
- <script src="/rbcli/js/html5shiv-printshiv.min.js?1561087612"></script>
1238
- <script src="/rbcli/js/highlight.pack.js?1561087612"></script>
1243
+ <script src="/rbcli/js/clipboard.min.js?1596148729"></script>
1244
+ <script src="/rbcli/js/perfect-scrollbar.min.js?1596148729"></script>
1245
+ <script src="/rbcli/js/perfect-scrollbar.jquery.min.js?1596148729"></script>
1246
+ <script src="/rbcli/js/jquery.sticky.js?1596148729"></script>
1247
+ <script src="/rbcli/js/featherlight.min.js?1596148729"></script>
1248
+ <script src="/rbcli/js/highlight.pack.js?1596148729"></script>
1239
1249
  <script>hljs.initHighlightingOnLoad();</script>
1240
- <script src="/rbcli/js/modernizr.custom-3.6.0.js?1561087612"></script>
1241
- <script src="/rbcli/js/learn.js?1561087612"></script>
1242
- <script src="/rbcli/js/hugo-learn.js?1561087612"></script>
1250
+ <script src="/rbcli/js/modernizr.custom-3.6.0.js?1596148729"></script>
1251
+ <script src="/rbcli/js/learn.js?1596148729"></script>
1252
+ <script src="/rbcli/js/hugo-learn.js?1596148729"></script>
1243
1253
 
1244
- <link href="/rbcli/mermaid/mermaid.css?1561087612" rel="stylesheet" />
1245
- <script src="/rbcli/mermaid/mermaid.js?1561087612"></script>
1254
+ <link href="/rbcli/mermaid/mermaid.css?1596148729" rel="stylesheet" />
1255
+ <script src="/rbcli/mermaid/mermaid.js?1596148729"></script>
1246
1256
  <script>
1247
1257
  mermaid.initialize({ startOnLoad: true });
1248
1258
  </script>