rbcli 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/Gemfile.lock +19 -5
  4. data/docs/404.html +9 -9
  5. data/docs/advanced/automatic_updates/index.html +30 -30
  6. data/docs/advanced/command_types/index.html +78 -78
  7. data/docs/advanced/distributed_state_locking/index.html +30 -30
  8. data/docs/advanced/hooks/index.html +42 -42
  9. data/docs/advanced/index.html +27 -27
  10. data/docs/advanced/index.xml +12 -50
  11. data/docs/advanced/interactive_commands/index.html +35 -35
  12. data/docs/advanced/logging/index.html +36 -36
  13. data/docs/advanced/remote_execution/index.html +51 -51
  14. data/docs/advanced/state_storage/index.html +34 -34
  15. data/docs/advanced/user_config_files/index.html +30 -30
  16. data/docs/categories/index.html +27 -27
  17. data/docs/categories/index.xml +3 -2
  18. data/docs/development/changelog/index.html +91 -60
  19. data/docs/development/code_of_conduct/index.html +27 -27
  20. data/docs/development/contributing/index.html +40 -40
  21. data/docs/development/index.html +27 -27
  22. data/docs/development/index.xml +6 -16
  23. data/docs/development/license/index.html +26 -26
  24. data/docs/index.html +26 -26
  25. data/docs/index.json +15 -15
  26. data/docs/index.xml +20 -90
  27. data/docs/quick_reference/index.html +54 -54
  28. data/docs/quick_reference/index.xml +3 -2
  29. data/docs/sitemap.xml +0 -1
  30. data/docs/tags/index.html +27 -27
  31. data/docs/tags/index.xml +3 -2
  32. data/docs/tutorial/10-getting_started/index.html +33 -33
  33. data/docs/tutorial/20-project_layout/index.html +55 -55
  34. data/docs/tutorial/30-your_first_command/index.html +90 -90
  35. data/docs/tutorial/40-options_parameters_and_arguments/index.html +167 -167
  36. data/docs/tutorial/50-publishing/index.html +30 -30
  37. data/docs/tutorial/index.html +27 -27
  38. data/docs/tutorial/index.xml +8 -28
  39. data/docs/whoami/index.html +28 -28
  40. data/docs/whoami/index.xml +3 -2
  41. data/docs-src/.hugo_build.lock +0 -0
  42. data/docs-src/content/development/changelog.md +20 -0
  43. data/docs-src/makesite.sh +4 -4
  44. data/lib/rbcli/engine/command.rb +1 -1
  45. data/lib/rbcli/engine/parser.rb +9 -7
  46. data/lib/rbcli/util/optimist.rb +1063 -0
  47. data/lib/rbcli/version.rb +1 -1
  48. data/lib/rbcli-tool/util.rb +1 -1
  49. data/rbcli.gemspec +7 -3
  50. data/skeletons/micro/executable +6 -1
  51. data/skeletons/mini/executable +6 -1
  52. data/skeletons/project/untitled.gemspec +4 -4
  53. metadata +9 -8
  54. data/lib/rbcli/util/trollop.rb +0 -1050
@@ -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.88.1" />
6
+ <meta name="generator" content="Hugo 0.125.1">
7
7
  <meta name="description" content="">
8
8
 
9
9
 
@@ -12,21 +12,21 @@
12
12
  <title>Options, Parameters, and Arguments :: RBCli Documentation</title>
13
13
 
14
14
 
15
- <link href="/rbcli/css/nucleus.css?1634703589" rel="stylesheet">
16
- <link href="/rbcli/css/fontawesome-all.min.css?1634703589" rel="stylesheet">
17
- <link href="/rbcli/css/hybrid.css?1634703589" rel="stylesheet">
18
- <link href="/rbcli/css/featherlight.min.css?1634703589" rel="stylesheet">
19
- <link href="/rbcli/css/perfect-scrollbar.min.css?1634703589" rel="stylesheet">
20
- <link href="/rbcli/css/auto-complete.css?1634703589" rel="stylesheet">
21
- <link href="/rbcli/css/atom-one-dark-reasonable.css?1634703589" rel="stylesheet">
22
- <link href="/rbcli/css/theme.css?1634703589" rel="stylesheet">
23
- <link href="/rbcli/css/hugo-theme.css?1634703589" rel="stylesheet">
15
+ <link href="/rbcli/css/nucleus.css?1713907739" rel="stylesheet">
16
+ <link href="/rbcli/css/fontawesome-all.min.css?1713907739" rel="stylesheet">
17
+ <link href="/rbcli/css/hybrid.css?1713907739" rel="stylesheet">
18
+ <link href="/rbcli/css/featherlight.min.css?1713907739" rel="stylesheet">
19
+ <link href="/rbcli/css/perfect-scrollbar.min.css?1713907739" rel="stylesheet">
20
+ <link href="/rbcli/css/auto-complete.css?1713907739" rel="stylesheet">
21
+ <link href="/rbcli/css/atom-one-dark-reasonable.css?1713907739" rel="stylesheet">
22
+ <link href="/rbcli/css/theme.css?1713907739" rel="stylesheet">
23
+ <link href="/rbcli/css/hugo-theme.css?1713907739" rel="stylesheet">
24
24
 
25
- <link href="/rbcli/css/theme-blue.css?1634703589" rel="stylesheet">
25
+ <link href="/rbcli/css/theme-blue.css?1713907739" rel="stylesheet">
26
26
 
27
27
 
28
28
 
29
- <script src="/rbcli/js/jquery-3.3.1.min.js?1634703589"></script>
29
+ <script src="/rbcli/js/jquery-3.3.1.min.js?1713907739"></script>
30
30
 
31
31
  <style>
32
32
  :root #header + #content > #left > #rlblock_left{
@@ -55,14 +55,14 @@
55
55
  <span data-search-clear=""><i class="fas fa-times"></i></span>
56
56
  </div>
57
57
 
58
- <script type="text/javascript" src="/rbcli/js/lunr.min.js?1634703589"></script>
59
- <script type="text/javascript" src="/rbcli/js/auto-complete.js?1634703589"></script>
58
+ <script type="text/javascript" src="/rbcli/js/lunr.min.js?1713907739"></script>
59
+ <script type="text/javascript" src="/rbcli/js/auto-complete.js?1713907739"></script>
60
60
  <script type="text/javascript">
61
61
 
62
62
  var baseurl = "https:\/\/akhoury6.github.io\/rbcli\/";
63
63
 
64
64
  </script>
65
- <script type="text/javascript" src="/rbcli/js/search.js?1634703589"></script>
65
+ <script type="text/javascript" src="/rbcli/js/search.js?1713907739"></script>
66
66
 
67
67
 
68
68
  </div>
@@ -730,165 +730,165 @@
730
730
  <li><strong>Arguments</strong> are strings that don&rsquo;t begin with a &lsquo;-&rsquo;, and are passed to the command&rsquo;s code as an array. These can be used as subcommands or additional parameters for your command.</li>
731
731
  </ul>
732
732
  <p>So a valid command could look something like these:</p>
733
- <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell">mytool -n load --filename<span style="color:#f92672">=</span>foo.txt
734
- mytool parse foo.txt
735
- mytool show -l
736
- </code></pre></div><p>Note that all options and parameters will have both a short and long version of the parameter available for use.</p>
733
+ <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>mytool -n load --filename<span style="color:#f92672">=</span>foo.txt
734
+ </span></span><span style="display:flex;"><span>mytool parse foo.txt
735
+ </span></span><span style="display:flex;"><span>mytool show -l
736
+ </span></span></code></pre></div><p>Note that all options and parameters will have both a short and long version of the parameter available for use.</p>
737
737
  <p>So let&rsquo;s take a look at how we define them.</p>
738
738
  <h2 id="options">Options</h2>
739
739
  <p>You can find the options declarations under <code>application/options.rb</code>. You&rsquo;ll see the example in the code:</p>
740
- <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-ruby" data-lang="ruby">option <span style="color:#e6db74">:name</span>, <span style="color:#e6db74">&#39;Give me your name&#39;</span>, <span style="color:#e6db74">short</span>: <span style="color:#e6db74">&#39;n&#39;</span>, <span style="color:#e6db74">type</span>: <span style="color:#e6db74">:string</span>, <span style="color:#e6db74">default</span>: <span style="color:#e6db74">&#39;Jack&#39;</span>, <span style="color:#e6db74">required</span>: <span style="color:#66d9ef">false</span>, <span style="color:#e6db74">permitted</span>: <span style="color:#f92672">[</span><span style="color:#e6db74">&#39;Jack&#39;</span>, <span style="color:#e6db74">&#39;Jill&#39;</span><span style="color:#f92672">]</span>
741
- </code></pre></div><p>This won&rsquo;t do for our tool, so let&rsquo;s change it. Remember that these options will be applicable to all of our commands, so lets make it something appropriate:</p>
742
- <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-ruby" data-lang="ruby">option <span style="color:#e6db74">:color</span>, <span style="color:#e6db74">&#39;Enable color output&#39;</span>, <span style="color:#e6db74">short</span>: <span style="color:#e6db74">&#39;c&#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>
743
- </code></pre></div><p>So now, let&rsquo;s take advantage of this flag in our <code>list</code> command. Let&rsquo;s change our block to:</p>
744
- <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-ruby" data-lang="ruby"> action <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>params, args, global_opts, config<span style="color:#f92672">|</span>
745
- <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>
746
- 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>
747
- 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
748
-
749
- <span style="color:#75715e"># We change the color based on the kind of file shown</span>
750
- <span style="color:#66d9ef">if</span> global_opts<span style="color:#f92672">[</span><span style="color:#e6db74">:color</span><span style="color:#f92672">]</span>
751
- <span style="color:#66d9ef">if</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>directory? filename
752
- outname <span style="color:#f92672">=</span> outname<span style="color:#f92672">.</span>light_blue
753
- <span style="color:#66d9ef">elsif</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>executable? filename
754
- outname <span style="color:#f92672">=</span> outname<span style="color:#f92672">.</span>light_green
755
- <span style="color:#66d9ef">end</span>
756
- <span style="color:#66d9ef">end</span>
757
-
758
- puts outname
759
- <span style="color:#66d9ef">end</span>
760
- <span style="color:#66d9ef">end</span>
761
- </code></pre></div><p>Notice how we referenced the value by using <code>global_opts[:color]</code>. It&rsquo;s that simple. To see it in action, run:</p>
762
- <div class="highlight"><pre tabindex="0" 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 -c list
763
- </code></pre></div><h2 id="parameters">Parameters</h2>
740
+ <div class="highlight"><pre tabindex="0" 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="display:flex;"><span>option <span style="color:#e6db74">:name</span>, <span style="color:#e6db74">&#39;Give me your name&#39;</span>, <span style="color:#e6db74">short</span>: <span style="color:#e6db74">&#39;n&#39;</span>, <span style="color:#e6db74">type</span>: <span style="color:#e6db74">:string</span>, <span style="color:#e6db74">default</span>: <span style="color:#e6db74">&#39;Jack&#39;</span>, <span style="color:#e6db74">required</span>: <span style="color:#66d9ef">false</span>, <span style="color:#e6db74">permitted</span>: <span style="color:#f92672">[</span><span style="color:#e6db74">&#39;Jack&#39;</span>, <span style="color:#e6db74">&#39;Jill&#39;</span><span style="color:#f92672">]</span>
741
+ </span></span></code></pre></div><p>This won&rsquo;t do for our tool, so let&rsquo;s change it. Remember that these options will be applicable to all of our commands, so lets make it something appropriate:</p>
742
+ <div class="highlight"><pre tabindex="0" 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="display:flex;"><span>option <span style="color:#e6db74">:color</span>, <span style="color:#e6db74">&#39;Enable color output&#39;</span>, <span style="color:#e6db74">short</span>: <span style="color:#e6db74">&#39;c&#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>
743
+ </span></span></code></pre></div><p>So now, let&rsquo;s take advantage of this flag in our <code>list</code> command. Let&rsquo;s change our block to:</p>
744
+ <div class="highlight"><pre tabindex="0" 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="display:flex;"><span> action <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>params, args, global_opts, config<span style="color:#f92672">|</span>
745
+ </span></span><span style="display:flex;"><span> <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>
746
+ </span></span><span style="display:flex;"><span> 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>
747
+ </span></span><span style="display:flex;"><span> 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
748
+ </span></span><span style="display:flex;"><span>
749
+ </span></span><span style="display:flex;"><span> <span style="color:#75715e"># We change the color based on the kind of file shown</span>
750
+ </span></span><span style="display:flex;"><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>
751
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">if</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>directory? filename
752
+ </span></span><span style="display:flex;"><span> outname <span style="color:#f92672">=</span> outname<span style="color:#f92672">.</span>light_blue
753
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">elsif</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>executable? filename
754
+ </span></span><span style="display:flex;"><span> outname <span style="color:#f92672">=</span> outname<span style="color:#f92672">.</span>light_green
755
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span>
756
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span>
757
+ </span></span><span style="display:flex;"><span>
758
+ </span></span><span style="display:flex;"><span> puts outname
759
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span>
760
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span>
761
+ </span></span></code></pre></div><p>Notice how we referenced the value by using <code>global_opts[:color]</code>. It&rsquo;s that simple. To see it in action, run:</p>
762
+ <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>mytool -c list
763
+ </span></span></code></pre></div><h2 id="parameters">Parameters</h2>
764
764
  <p>Parameters work the same way as options, but they are localized to only the selected command. They are declared - as you probably guessed by now - in the command&rsquo;s class. So let&rsquo;s add the following lines to our list command within the class declaration:</p>
765
- <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-ruby" data-lang="ruby">parameter <span style="color:#e6db74">:sort</span>, <span style="color:#e6db74">&#39;Sort output alphabetically&#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>
766
- parameter <span style="color:#e6db74">:all</span>, <span style="color:#e6db74">&#39;Show hidden files&#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>
767
- parameter <span style="color:#e6db74">:directoriesfirst</span>, <span style="color:#e6db74">&#39;Show directories on top&#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>
768
- </code></pre></div><p>And let&rsquo;s modify our action block to utilize them:</p>
769
- <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-ruby" data-lang="ruby"> action <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>params, args, global_opts, config<span style="color:#f92672">|</span>
770
- filelist <span style="color:#f92672">=</span> <span style="color:#f92672">[]</span>
771
-
772
- <span style="color:#75715e"># We include dotfiles if specified</span>
773
- include_dotfiles <span style="color:#f92672">=</span> (params<span style="color:#f92672">[</span><span style="color:#e6db74">:all</span><span style="color:#f92672">]</span>) ? <span style="color:#66d9ef">File</span><span style="color:#f92672">::</span><span style="color:#66d9ef">FNM_DOTMATCH</span> : <span style="color:#ae81ff">0</span>
774
-
775
- <span style="color:#75715e"># We store a list of the files in an array, including dotfiles if specified</span>
776
- <span style="color:#66d9ef">Dir</span><span style="color:#f92672">.</span>glob <span style="color:#e6db74">&#34;./*&#34;</span>, include_dotfiles <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>filename<span style="color:#f92672">|</span>
777
- 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>
778
- 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
779
- filelist<span style="color:#f92672">.</span>append outname
780
- <span style="color:#66d9ef">end</span>
781
-
782
- <span style="color:#75715e"># Sort alphabetically if specified</span>
783
- filelist<span style="color:#f92672">.</span>sort! <span style="color:#66d9ef">if</span> params<span style="color:#f92672">[</span><span style="color:#e6db74">:sort</span><span style="color:#f92672">]</span>
784
-
785
- <span style="color:#75715e"># Put directories first if specified</span>
786
- <span style="color:#66d9ef">if</span> params<span style="color:#f92672">[</span><span style="color:#e6db74">:directoriesfirst</span><span style="color:#f92672">]</span>
787
- files <span style="color:#f92672">=</span> <span style="color:#f92672">[]</span>; dirs <span style="color:#f92672">=</span> <span style="color:#f92672">[]</span>
788
- filelist<span style="color:#f92672">.</span>each <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>filename<span style="color:#f92672">|</span>
789
- <span style="color:#66d9ef">if</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>directory? filename
790
- dirs<span style="color:#f92672">.</span>append(filename)
791
- <span style="color:#66d9ef">else</span>
792
- files<span style="color:#f92672">.</span>append(filename)
793
- <span style="color:#66d9ef">end</span>
794
- <span style="color:#66d9ef">end</span>
795
- filelist <span style="color:#f92672">=</span> dirs <span style="color:#f92672">+</span> files
796
- <span style="color:#66d9ef">end</span>
797
-
798
- <span style="color:#75715e"># Apply color. We do this at the end now because color codes can alter the sorting.</span>
799
- filelist<span style="color:#f92672">.</span>map! <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>filename<span style="color:#f92672">|</span>
800
- <span style="color:#66d9ef">if</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>directory? filename
801
- filename<span style="color:#f92672">.</span>light_blue
802
- <span style="color:#66d9ef">elsif</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>executable? filename
803
- filename<span style="color:#f92672">.</span>light_green
804
- <span style="color:#66d9ef">else</span>
805
- filename
806
- <span style="color:#66d9ef">end</span>
807
- <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>
808
-
809
- puts filelist
810
- <span style="color:#66d9ef">end</span>
811
- </code></pre></div><p>You should be able to run it now:</p>
812
- <div class="highlight"><pre tabindex="0" 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 -c list -asd
813
- </code></pre></div><p>Note how the parameters come after the <code>list</code> command in the syntax above. As you create more commands, each will have its own unique set of parameters, while the options remain <em>before</em> the command and are available to all of them.</p>
765
+ <div class="highlight"><pre tabindex="0" 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="display:flex;"><span>parameter <span style="color:#e6db74">:sort</span>, <span style="color:#e6db74">&#39;Sort output alphabetically&#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>
766
+ </span></span><span style="display:flex;"><span>parameter <span style="color:#e6db74">:all</span>, <span style="color:#e6db74">&#39;Show hidden files&#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>
767
+ </span></span><span style="display:flex;"><span>parameter <span style="color:#e6db74">:directoriesfirst</span>, <span style="color:#e6db74">&#39;Show directories on top&#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>
768
+ </span></span></code></pre></div><p>And let&rsquo;s modify our action block to utilize them:</p>
769
+ <div class="highlight"><pre tabindex="0" 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="display:flex;"><span> action <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>params, args, global_opts, config<span style="color:#f92672">|</span>
770
+ </span></span><span style="display:flex;"><span> filelist <span style="color:#f92672">=</span> <span style="color:#f92672">[]</span>
771
+ </span></span><span style="display:flex;"><span>
772
+ </span></span><span style="display:flex;"><span> <span style="color:#75715e"># We include dotfiles if specified</span>
773
+ </span></span><span style="display:flex;"><span> include_dotfiles <span style="color:#f92672">=</span> (params<span style="color:#f92672">[</span><span style="color:#e6db74">:all</span><span style="color:#f92672">]</span>) ? <span style="color:#66d9ef">File</span><span style="color:#f92672">::</span><span style="color:#66d9ef">FNM_DOTMATCH</span> : <span style="color:#ae81ff">0</span>
774
+ </span></span><span style="display:flex;"><span>
775
+ </span></span><span style="display:flex;"><span> <span style="color:#75715e"># We store a list of the files in an array, including dotfiles if specified</span>
776
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">Dir</span><span style="color:#f92672">.</span>glob <span style="color:#e6db74">&#34;./*&#34;</span>, include_dotfiles <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>filename<span style="color:#f92672">|</span>
777
+ </span></span><span style="display:flex;"><span> 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>
778
+ </span></span><span style="display:flex;"><span> 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
779
+ </span></span><span style="display:flex;"><span> filelist<span style="color:#f92672">.</span>append outname
780
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span>
781
+ </span></span><span style="display:flex;"><span>
782
+ </span></span><span style="display:flex;"><span> <span style="color:#75715e"># Sort alphabetically if specified</span>
783
+ </span></span><span style="display:flex;"><span> filelist<span style="color:#f92672">.</span>sort! <span style="color:#66d9ef">if</span> params<span style="color:#f92672">[</span><span style="color:#e6db74">:sort</span><span style="color:#f92672">]</span>
784
+ </span></span><span style="display:flex;"><span>
785
+ </span></span><span style="display:flex;"><span> <span style="color:#75715e"># Put directories first if specified</span>
786
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">if</span> params<span style="color:#f92672">[</span><span style="color:#e6db74">:directoriesfirst</span><span style="color:#f92672">]</span>
787
+ </span></span><span style="display:flex;"><span> files <span style="color:#f92672">=</span> <span style="color:#f92672">[]</span>; dirs <span style="color:#f92672">=</span> <span style="color:#f92672">[]</span>
788
+ </span></span><span style="display:flex;"><span> filelist<span style="color:#f92672">.</span>each <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>filename<span style="color:#f92672">|</span>
789
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">if</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>directory? filename
790
+ </span></span><span style="display:flex;"><span> dirs<span style="color:#f92672">.</span>append(filename)
791
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">else</span>
792
+ </span></span><span style="display:flex;"><span> files<span style="color:#f92672">.</span>append(filename)
793
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span>
794
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span>
795
+ </span></span><span style="display:flex;"><span> filelist <span style="color:#f92672">=</span> dirs <span style="color:#f92672">+</span> files
796
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span>
797
+ </span></span><span style="display:flex;"><span>
798
+ </span></span><span style="display:flex;"><span> <span style="color:#75715e"># Apply color. We do this at the end now because color codes can alter the sorting.</span>
799
+ </span></span><span style="display:flex;"><span> filelist<span style="color:#f92672">.</span>map! <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>filename<span style="color:#f92672">|</span>
800
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">if</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>directory? filename
801
+ </span></span><span style="display:flex;"><span> filename<span style="color:#f92672">.</span>light_blue
802
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">elsif</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>executable? filename
803
+ </span></span><span style="display:flex;"><span> filename<span style="color:#f92672">.</span>light_green
804
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">else</span>
805
+ </span></span><span style="display:flex;"><span> filename
806
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span>
807
+ </span></span><span style="display:flex;"><span> <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>
808
+ </span></span><span style="display:flex;"><span>
809
+ </span></span><span style="display:flex;"><span> puts filelist
810
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span>
811
+ </span></span></code></pre></div><p>You should be able to run it now:</p>
812
+ <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>mytool -c list -asd
813
+ </span></span></code></pre></div><p>Note how the parameters come after the <code>list</code> command in the syntax above. As you create more commands, each will have its own unique set of parameters, while the options remain <em>before</em> the command and are available to all of them.</p>
814
814
  <h3 id="user-prompting">User Prompting</h3>
815
815
  <p>There is an additional option when declaring parameters to prompt the user for a value if not entered on the command line. This can be done with the <code>prompt:</code> keyword. Let&rsquo;s change one of our parameters to utilize it:</p>
816
- <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-ruby" data-lang="ruby">parameter <span style="color:#e6db74">:sort</span>, <span style="color:#e6db74">&#39;Sort output alphabetically&#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">prompt</span>: <span style="color:#e6db74">&#34;Sort output alphabetically?&#34;</span>
817
- </code></pre></div><p>Now, let&rsquo;s run the tool while omitting the <code>--sort</code> parameter, as such:</p>
818
- <div class="highlight"><pre tabindex="0" 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 -c list -ad
819
- </code></pre></div><p>This should give you the prompt:</p>
816
+ <div class="highlight"><pre tabindex="0" 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="display:flex;"><span>parameter <span style="color:#e6db74">:sort</span>, <span style="color:#e6db74">&#39;Sort output alphabetically&#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">prompt</span>: <span style="color:#e6db74">&#34;Sort output alphabetically?&#34;</span>
817
+ </span></span></code></pre></div><p>Now, let&rsquo;s run the tool while omitting the <code>--sort</code> parameter, as such:</p>
818
+ <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>mytool -c list -ad
819
+ </span></span></code></pre></div><p>This should give you the prompt:</p>
820
820
  <pre tabindex="0"><code>Sort output alphabetically? (y/N):
821
821
  </code></pre><p>Because we set the parameter to default to <code>false</code> the default here is <code>N</code>, which is used if the user hits enter without entering a letter. If the default was set to <code>true</code>, then the <code>Y</code> would be capitalized and be the default.</p>
822
822
  <p>For more information, see the documentation on <a href="/rbcli/advanced/interactive_commands/">Interactive Commands</a>.</p>
823
823
  <h2 id="arguments">Arguments</h2>
824
824
  <p>Lastly on the command line, there are arguments. Arguments are simply strings without the <code>-</code> character in front, and automatically get passed into an array in your applicaiton. Let&rsquo;s take a look at how we can use them.</p>
825
825
  <p>Unlike options and parameters, arguments require no setup. So let&rsquo;s assume that we want any arguments passed to the <code>list</code> command to be filenames that you want to display, and that you can pass multiple ones. Since arguments aren&rsquo;t listed automatically by the help function, this is a good example of what to put in your usage text. Let&rsquo;s take a look at what our class looks like now:</p>
826
- <div class="highlight"><pre tabindex="0" 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>
827
- description <span style="color:#e6db74">%q{List files in current directory}</span>
828
- usage <span style="color:#e6db74">&lt;&lt;-EOF
829
- </span><span style="color:#e6db74"></span><span style="color:#66d9ef">To</span> list only specific files, you can enter filenames as arguments
830
-
831
- mytool list filename1 filename2<span style="color:#f92672">...</span>
832
- <span style="color:#66d9ef">EOF</span>
833
- parameter <span style="color:#e6db74">:sort</span>, <span style="color:#e6db74">&#39;Sort output alphabetically&#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>
834
- parameter <span style="color:#e6db74">:all</span>, <span style="color:#e6db74">&#39;Show hidden files&#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>
835
- parameter <span style="color:#e6db74">:directoriesfirst</span>, <span style="color:#e6db74">&#39;Show directories on top&#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>
836
-
837
- action <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>params, args, global_opts, config<span style="color:#f92672">|</span>
838
- filelist <span style="color:#f92672">=</span> <span style="color:#f92672">[]</span>
839
-
840
- <span style="color:#75715e"># We include dotfiles if specified</span>
841
- include_dotfiles <span style="color:#f92672">=</span> (params<span style="color:#f92672">[</span><span style="color:#e6db74">:all</span><span style="color:#f92672">]</span>) ? <span style="color:#66d9ef">File</span><span style="color:#f92672">::</span><span style="color:#66d9ef">FNM_DOTMATCH</span> : <span style="color:#ae81ff">0</span>
842
-
843
- <span style="color:#75715e"># We store a list of the files in an array, including dotfiles if specified</span>
844
- <span style="color:#66d9ef">Dir</span><span style="color:#f92672">.</span>glob <span style="color:#e6db74">&#34;./*&#34;</span>, include_dotfiles <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>filename<span style="color:#f92672">|</span>
845
- 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>
846
- <span style="color:#66d9ef">next</span> <span style="color:#66d9ef">unless</span> args<span style="color:#f92672">.</span>include? outname <span style="color:#66d9ef">if</span> args<span style="color:#f92672">.</span>length <span style="color:#f92672">&gt;</span> <span style="color:#ae81ff">0</span>
847
- 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
848
- filelist<span style="color:#f92672">.</span>append outname
849
- <span style="color:#66d9ef">end</span>
850
-
851
- <span style="color:#75715e"># Sort alphabetically if specified</span>
852
- filelist<span style="color:#f92672">.</span>sort! <span style="color:#66d9ef">if</span> params<span style="color:#f92672">[</span><span style="color:#e6db74">:sort</span><span style="color:#f92672">]</span>
853
-
854
- <span style="color:#75715e"># Put directories first if specified</span>
855
- <span style="color:#66d9ef">if</span> params<span style="color:#f92672">[</span><span style="color:#e6db74">:directoriesfirst</span><span style="color:#f92672">]</span>
856
- files <span style="color:#f92672">=</span> <span style="color:#f92672">[]</span>; dirs <span style="color:#f92672">=</span> <span style="color:#f92672">[]</span>
857
- filelist<span style="color:#f92672">.</span>each <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>filename<span style="color:#f92672">|</span>
858
- <span style="color:#66d9ef">if</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>directory? filename
859
- dirs<span style="color:#f92672">.</span>append(filename)
860
- <span style="color:#66d9ef">else</span>
861
- files<span style="color:#f92672">.</span>append(filename)
862
- <span style="color:#66d9ef">end</span>
863
- <span style="color:#66d9ef">end</span>
864
- filelist <span style="color:#f92672">=</span> dirs <span style="color:#f92672">+</span> files
865
- <span style="color:#66d9ef">end</span>
866
-
867
- <span style="color:#75715e"># Apply color. We do this at the end because color codes can alter the sorting</span>
868
- filelist<span style="color:#f92672">.</span>map! <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>filename<span style="color:#f92672">|</span>
869
- <span style="color:#66d9ef">if</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>directory? filename
870
- filename<span style="color:#f92672">.</span>light_blue
871
- <span style="color:#66d9ef">elsif</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>executable? filename
872
- filename<span style="color:#f92672">.</span>light_green
873
- <span style="color:#66d9ef">else</span>
874
- filename
875
- <span style="color:#66d9ef">end</span>
876
- <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>
877
-
878
- puts filelist
879
- <span style="color:#66d9ef">end</span>
880
- <span style="color:#66d9ef">end</span>
881
- </code></pre></div><h2 id="simplified-reference-tldr">Simplified Reference (TLDR)</h2>
826
+ <div class="highlight"><pre tabindex="0" 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="display:flex;"><span><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>
827
+ </span></span><span style="display:flex;"><span> description <span style="color:#e6db74">%q{List files in current directory}</span>
828
+ </span></span><span style="display:flex;"><span> usage <span style="color:#e6db74">&lt;&lt;-EOF
829
+ </span></span></span><span style="display:flex;"><span><span style="color:#e6db74"></span><span style="color:#66d9ef">To</span> list only specific files, you can enter filenames as arguments
830
+ </span></span><span style="display:flex;"><span>
831
+ </span></span><span style="display:flex;"><span> mytool list filename1 filename2<span style="color:#f92672">...</span>
832
+ </span></span><span style="display:flex;"><span><span style="color:#66d9ef">EOF</span>
833
+ </span></span><span style="display:flex;"><span> parameter <span style="color:#e6db74">:sort</span>, <span style="color:#e6db74">&#39;Sort output alphabetically&#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>
834
+ </span></span><span style="display:flex;"><span> parameter <span style="color:#e6db74">:all</span>, <span style="color:#e6db74">&#39;Show hidden files&#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>
835
+ </span></span><span style="display:flex;"><span> parameter <span style="color:#e6db74">:directoriesfirst</span>, <span style="color:#e6db74">&#39;Show directories on top&#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>
836
+ </span></span><span style="display:flex;"><span>
837
+ </span></span><span style="display:flex;"><span> action <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>params, args, global_opts, config<span style="color:#f92672">|</span>
838
+ </span></span><span style="display:flex;"><span> filelist <span style="color:#f92672">=</span> <span style="color:#f92672">[]</span>
839
+ </span></span><span style="display:flex;"><span>
840
+ </span></span><span style="display:flex;"><span> <span style="color:#75715e"># We include dotfiles if specified</span>
841
+ </span></span><span style="display:flex;"><span> include_dotfiles <span style="color:#f92672">=</span> (params<span style="color:#f92672">[</span><span style="color:#e6db74">:all</span><span style="color:#f92672">]</span>) ? <span style="color:#66d9ef">File</span><span style="color:#f92672">::</span><span style="color:#66d9ef">FNM_DOTMATCH</span> : <span style="color:#ae81ff">0</span>
842
+ </span></span><span style="display:flex;"><span>
843
+ </span></span><span style="display:flex;"><span> <span style="color:#75715e"># We store a list of the files in an array, including dotfiles if specified</span>
844
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">Dir</span><span style="color:#f92672">.</span>glob <span style="color:#e6db74">&#34;./*&#34;</span>, include_dotfiles <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>filename<span style="color:#f92672">|</span>
845
+ </span></span><span style="display:flex;"><span> 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>
846
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">next</span> <span style="color:#66d9ef">unless</span> args<span style="color:#f92672">.</span>include? outname <span style="color:#66d9ef">if</span> args<span style="color:#f92672">.</span>length <span style="color:#f92672">&gt;</span> <span style="color:#ae81ff">0</span>
847
+ </span></span><span style="display:flex;"><span> 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
848
+ </span></span><span style="display:flex;"><span> filelist<span style="color:#f92672">.</span>append outname
849
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span>
850
+ </span></span><span style="display:flex;"><span>
851
+ </span></span><span style="display:flex;"><span> <span style="color:#75715e"># Sort alphabetically if specified</span>
852
+ </span></span><span style="display:flex;"><span> filelist<span style="color:#f92672">.</span>sort! <span style="color:#66d9ef">if</span> params<span style="color:#f92672">[</span><span style="color:#e6db74">:sort</span><span style="color:#f92672">]</span>
853
+ </span></span><span style="display:flex;"><span>
854
+ </span></span><span style="display:flex;"><span> <span style="color:#75715e"># Put directories first if specified</span>
855
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">if</span> params<span style="color:#f92672">[</span><span style="color:#e6db74">:directoriesfirst</span><span style="color:#f92672">]</span>
856
+ </span></span><span style="display:flex;"><span> files <span style="color:#f92672">=</span> <span style="color:#f92672">[]</span>; dirs <span style="color:#f92672">=</span> <span style="color:#f92672">[]</span>
857
+ </span></span><span style="display:flex;"><span> filelist<span style="color:#f92672">.</span>each <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>filename<span style="color:#f92672">|</span>
858
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">if</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>directory? filename
859
+ </span></span><span style="display:flex;"><span> dirs<span style="color:#f92672">.</span>append(filename)
860
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">else</span>
861
+ </span></span><span style="display:flex;"><span> files<span style="color:#f92672">.</span>append(filename)
862
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span>
863
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span>
864
+ </span></span><span style="display:flex;"><span> filelist <span style="color:#f92672">=</span> dirs <span style="color:#f92672">+</span> files
865
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span>
866
+ </span></span><span style="display:flex;"><span>
867
+ </span></span><span style="display:flex;"><span> <span style="color:#75715e"># Apply color. We do this at the end because color codes can alter the sorting</span>
868
+ </span></span><span style="display:flex;"><span> filelist<span style="color:#f92672">.</span>map! <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>filename<span style="color:#f92672">|</span>
869
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">if</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>directory? filename
870
+ </span></span><span style="display:flex;"><span> filename<span style="color:#f92672">.</span>light_blue
871
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">elsif</span> <span style="color:#66d9ef">File</span><span style="color:#f92672">.</span>executable? filename
872
+ </span></span><span style="display:flex;"><span> filename<span style="color:#f92672">.</span>light_green
873
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">else</span>
874
+ </span></span><span style="display:flex;"><span> filename
875
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span>
876
+ </span></span><span style="display:flex;"><span> <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>
877
+ </span></span><span style="display:flex;"><span>
878
+ </span></span><span style="display:flex;"><span> puts filelist
879
+ </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span>
880
+ </span></span><span style="display:flex;"><span><span style="color:#66d9ef">end</span>
881
+ </span></span></code></pre></div><h2 id="simplified-reference-tldr">Simplified Reference (TLDR)</h2>
882
882
  <p>RBCli enforces a CLI structure of:</p>
883
883
  <pre tabindex="0"><code>toolname [options] command [parameters] argument1 argument2...
884
884
  </code></pre><p><strong>Options</strong> are declared in <code>application/options.rb</code> file.</p>
885
885
  <p><strong>Parameters</strong> are declared in the respective command&rsquo;s class declaration.</p>
886
886
  <p><strong>Arguments</strong> don&rsquo;t need to be declared, and are passed in as an array to your commands. It is helpful to describe the argument purpose in the <code>usage</code> text declaration so that the user can see what to do in the help.</p>
887
887
  <p><strong>Options</strong> and <strong>parameters</strong> both use the same format:</p>
888
- <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-ruby" data-lang="ruby">option <span style="color:#e6db74">:&lt;</span>name<span style="color:#f92672">&gt;</span>, <span style="color:#e6db74">&#34;&lt;description_string&gt;&#34;</span>, <span style="color:#e6db74">short</span>: <span style="color:#e6db74">&#39;&lt;character&gt;&#39;</span>, <span style="color:#e6db74">type</span>: <span style="color:#f92672">&lt;</span>variable_type<span style="color:#f92672">&gt;</span>, <span style="color:#e6db74">default</span>: <span style="color:#f92672">&lt;</span>default_value<span style="color:#f92672">&gt;</span>, <span style="color:#e6db74">permitted</span>: <span style="color:#f92672">[&lt;</span>array_of_permitted_values<span style="color:#f92672">]</span>
889
-
890
- parameter <span style="color:#e6db74">:&lt;</span>name<span style="color:#f92672">&gt;</span>, <span style="color:#e6db74">&#34;&lt;description_string&gt;&#34;</span>, <span style="color:#e6db74">short</span>: <span style="color:#e6db74">&#39;&lt;character&gt;&#39;</span>, <span style="color:#e6db74">type</span>: <span style="color:#f92672">&lt;</span>variable_type<span style="color:#f92672">&gt;</span>, <span style="color:#e6db74">default</span>: <span style="color:#f92672">&lt;</span>default_value<span style="color:#f92672">&gt;</span>, <span style="color:#e6db74">permitted</span>: <span style="color:#f92672">[&lt;</span>array_of_permitted_values<span style="color:#f92672">]</span>
891
- </code></pre></div><ul>
888
+ <div class="highlight"><pre tabindex="0" 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="display:flex;"><span>option <span style="color:#e6db74">:&lt;</span>name<span style="color:#f92672">&gt;</span>, <span style="color:#e6db74">&#34;&lt;description_string&gt;&#34;</span>, <span style="color:#e6db74">short</span>: <span style="color:#e6db74">&#39;&lt;character&gt;&#39;</span>, <span style="color:#e6db74">type</span>: <span style="color:#f92672">&lt;</span>variable_type<span style="color:#f92672">&gt;</span>, <span style="color:#e6db74">default</span>: <span style="color:#f92672">&lt;</span>default_value<span style="color:#f92672">&gt;</span>, <span style="color:#e6db74">permitted</span>: <span style="color:#f92672">[&lt;</span>array_of_permitted_values<span style="color:#f92672">]</span>
889
+ </span></span><span style="display:flex;"><span>
890
+ </span></span><span style="display:flex;"><span>parameter <span style="color:#e6db74">:&lt;</span>name<span style="color:#f92672">&gt;</span>, <span style="color:#e6db74">&#34;&lt;description_string&gt;&#34;</span>, <span style="color:#e6db74">short</span>: <span style="color:#e6db74">&#39;&lt;character&gt;&#39;</span>, <span style="color:#e6db74">type</span>: <span style="color:#f92672">&lt;</span>variable_type<span style="color:#f92672">&gt;</span>, <span style="color:#e6db74">default</span>: <span style="color:#f92672">&lt;</span>default_value<span style="color:#f92672">&gt;</span>, <span style="color:#e6db74">permitted</span>: <span style="color:#f92672">[&lt;</span>array_of_permitted_values<span style="color:#f92672">]</span>
891
+ </span></span></code></pre></div><ul>
892
892
  <li><code>name</code>
893
893
  <ul>
894
894
  <li>(Required) The long name of the option, as a symbol. This will be represented as <code>--name</code> on the command line</li>
@@ -1361,19 +1361,19 @@ parameter <span style="color:#e6db74">:&lt;</span>name<span style="color:#f92672
1361
1361
  <div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
1362
1362
  <div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
1363
1363
  </div>
1364
- <script src="/rbcli/js/clipboard.min.js?1634703589"></script>
1365
- <script src="/rbcli/js/perfect-scrollbar.min.js?1634703589"></script>
1366
- <script src="/rbcli/js/perfect-scrollbar.jquery.min.js?1634703589"></script>
1367
- <script src="/rbcli/js/jquery.sticky.js?1634703589"></script>
1368
- <script src="/rbcli/js/featherlight.min.js?1634703589"></script>
1369
- <script src="/rbcli/js/highlight.pack.js?1634703589"></script>
1364
+ <script src="/rbcli/js/clipboard.min.js?1713907739"></script>
1365
+ <script src="/rbcli/js/perfect-scrollbar.min.js?1713907739"></script>
1366
+ <script src="/rbcli/js/perfect-scrollbar.jquery.min.js?1713907739"></script>
1367
+ <script src="/rbcli/js/jquery.sticky.js?1713907739"></script>
1368
+ <script src="/rbcli/js/featherlight.min.js?1713907739"></script>
1369
+ <script src="/rbcli/js/highlight.pack.js?1713907739"></script>
1370
1370
  <script>hljs.initHighlightingOnLoad();</script>
1371
- <script src="/rbcli/js/modernizr.custom-3.6.0.js?1634703589"></script>
1372
- <script src="/rbcli/js/learn.js?1634703589"></script>
1373
- <script src="/rbcli/js/hugo-learn.js?1634703589"></script>
1371
+ <script src="/rbcli/js/modernizr.custom-3.6.0.js?1713907739"></script>
1372
+ <script src="/rbcli/js/learn.js?1713907739"></script>
1373
+ <script src="/rbcli/js/hugo-learn.js?1713907739"></script>
1374
1374
 
1375
- <link href="/rbcli/mermaid/mermaid.css?1634703589" rel="stylesheet" />
1376
- <script src="/rbcli/mermaid/mermaid.js?1634703589"></script>
1375
+ <link href="/rbcli/mermaid/mermaid.css?1713907739" rel="stylesheet" />
1376
+ <script src="/rbcli/mermaid/mermaid.js?1713907739"></script>
1377
1377
  <script>
1378
1378
  mermaid.initialize({ startOnLoad: true });
1379
1379
  </script>