rbcli 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/Gemfile.lock +63 -63
- data/docs/404.html +9 -9
- data/docs/advanced/automatic_updates/index.html +30 -30
- data/docs/advanced/command_types/index.html +78 -78
- data/docs/advanced/distributed_state_locking/index.html +30 -30
- data/docs/advanced/hooks/index.html +42 -42
- data/docs/advanced/index.html +27 -27
- data/docs/advanced/index.xml +12 -50
- data/docs/advanced/interactive_commands/index.html +35 -35
- data/docs/advanced/logging/index.html +36 -36
- data/docs/advanced/remote_execution/index.html +51 -51
- data/docs/advanced/state_storage/index.html +34 -34
- data/docs/advanced/user_config_files/index.html +30 -30
- data/docs/categories/index.html +27 -27
- data/docs/categories/index.xml +3 -2
- data/docs/development/changelog/index.html +91 -60
- data/docs/development/code_of_conduct/index.html +27 -27
- data/docs/development/contributing/index.html +40 -40
- data/docs/development/index.html +27 -27
- data/docs/development/index.xml +6 -16
- data/docs/development/license/index.html +26 -26
- data/docs/index.html +26 -26
- data/docs/index.json +15 -15
- data/docs/index.xml +20 -90
- data/docs/quick_reference/index.html +54 -54
- data/docs/quick_reference/index.xml +3 -2
- data/docs/sitemap.xml +0 -1
- data/docs/tags/index.html +27 -27
- data/docs/tags/index.xml +3 -2
- data/docs/tutorial/10-getting_started/index.html +33 -33
- data/docs/tutorial/20-project_layout/index.html +55 -55
- data/docs/tutorial/30-your_first_command/index.html +90 -90
- data/docs/tutorial/40-options_parameters_and_arguments/index.html +167 -167
- data/docs/tutorial/50-publishing/index.html +30 -30
- data/docs/tutorial/index.html +27 -27
- data/docs/tutorial/index.xml +8 -28
- data/docs/whoami/index.html +28 -28
- data/docs/whoami/index.xml +3 -2
- data/docs-src/.hugo_build.lock +0 -0
- data/docs-src/content/development/changelog.md +20 -0
- data/docs-src/makesite.sh +4 -4
- data/exe/rbcli +1 -1
- data/lib/rbcli/configuration/configurate.rb +1 -1
- data/lib/rbcli/engine/command.rb +1 -1
- data/lib/rbcli/engine/load_project.rb +1 -1
- data/lib/rbcli/engine/parser.rb +9 -7
- data/lib/rbcli/features/userconfig.rb +3 -3
- data/lib/rbcli/state_storage/localstate.rb +1 -1
- data/lib/rbcli/util/optimist.rb +1063 -0
- data/lib/rbcli/version.rb +1 -1
- data/lib/rbcli-tool/generators.rb +3 -3
- data/lib/rbcli-tool/mdless_fix.rb +1 -1
- data/lib/rbcli-tool/project.rb +3 -3
- data/lib/rbcli-tool/util.rb +3 -3
- data/rbcli.gemspec +16 -14
- data/skeletons/micro/executable +6 -1
- data/skeletons/mini/executable +6 -1
- data/skeletons/project/untitled.gemspec +4 -4
- metadata +31 -30
- 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.
|
|
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>Command Types :: RBCli Documentation</title>
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
<link href="/rbcli/css/nucleus.css?
|
|
16
|
-
<link href="/rbcli/css/fontawesome-all.min.css?
|
|
17
|
-
<link href="/rbcli/css/hybrid.css?
|
|
18
|
-
<link href="/rbcli/css/featherlight.min.css?
|
|
19
|
-
<link href="/rbcli/css/perfect-scrollbar.min.css?
|
|
20
|
-
<link href="/rbcli/css/auto-complete.css?
|
|
21
|
-
<link href="/rbcli/css/atom-one-dark-reasonable.css?
|
|
22
|
-
<link href="/rbcli/css/theme.css?
|
|
23
|
-
<link href="/rbcli/css/hugo-theme.css?
|
|
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?
|
|
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?
|
|
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?
|
|
59
|
-
<script type="text/javascript" src="/rbcli/js/auto-complete.js?
|
|
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?
|
|
65
|
+
<script type="text/javascript" src="/rbcli/js/search.js?1713907739"></script>
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
</div>
|
|
@@ -720,17 +720,17 @@
|
|
|
720
720
|
<p>This document is provided to be a reference. If you would like an in-depth tutorial, please see <a href="/rbcli/tutorial/30-your_first_command/">Your First Command</a>.</p>
|
|
721
721
|
<h2 id="general-command-structure">General Command Structure</h2>
|
|
722
722
|
<p>Commands in RBCli are created by subclassing <code>Rbcli::Command</code>. All commands share a certain common structure:</p>
|
|
723
|
-
<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"><</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>
|
|
724
|
-
description <span style="color:#e6db74">'TODO: Description goes here'</span> <span style="color:#75715e"># (Required) Short description for the global help</span>
|
|
725
|
-
usage <span style="color:#e6db74"><<-EOF
|
|
726
|
-
</span><span style="color:#e6db74"></span><span style="color:#e6db74">TODO</span>: <span style="color:#66d9ef">Usage</span> text goes here
|
|
727
|
-
|
|
728
|
-
parameter <span style="color:#e6db74">:force</span>, <span style="color:#e6db74">'Force testing'</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>
|
|
729
|
-
|
|
730
|
-
config_default <span style="color:#e6db74">:myopt2</span>, <span style="color:#e6db74">description</span>: <span style="color:#e6db74">'My Option #2'</span>, <span style="color:#e6db74">default</span>: <span style="color:#e6db74">'Default Value Here'</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>
|
|
731
|
-
<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>
|
|
732
|
-
|
|
733
|
-
</code></pre></div><ul>
|
|
723
|
+
<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"><</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>
|
|
724
|
+
</span></span><span style="display:flex;"><span> description <span style="color:#e6db74">'TODO: Description goes here'</span> <span style="color:#75715e"># (Required) Short description for the global help</span>
|
|
725
|
+
</span></span><span style="display:flex;"><span> usage <span style="color:#e6db74"><<-EOF
|
|
726
|
+
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"></span><span style="color:#e6db74">TODO</span>: <span style="color:#66d9ef">Usage</span> text goes here
|
|
727
|
+
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">EOF</span> <span style="color:#75715e"># (Required) Long description for the command-specific help</span>
|
|
728
|
+
</span></span><span style="display:flex;"><span> parameter <span style="color:#e6db74">:force</span>, <span style="color:#e6db74">'Force testing'</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>
|
|
729
|
+
</span></span><span style="display:flex;"><span>
|
|
730
|
+
</span></span><span style="display:flex;"><span> config_default <span style="color:#e6db74">:myopt2</span>, <span style="color:#e6db74">description</span>: <span style="color:#e6db74">'My Option #2'</span>, <span style="color:#e6db74">default</span>: <span style="color:#e6db74">'Default Value Here'</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>
|
|
731
|
+
</span></span><span style="display:flex;"><span> <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>
|
|
732
|
+
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">end</span>
|
|
733
|
+
</span></span></code></pre></div><ul>
|
|
734
734
|
<li><code>description</code>
|
|
735
735
|
<ul>
|
|
736
736
|
<li>A short description of the command, which will appear in the top-level help (when the user runs <code>mytool -h</code>).</li>
|
|
@@ -754,58 +754,58 @@
|
|
|
754
754
|
</ul>
|
|
755
755
|
<h2 id="standard-commands">Standard Commands</h2>
|
|
756
756
|
<p>Standard commands are written as ruby code. To create a standard command called <code>list</code>, run:</p>
|
|
757
|
-
<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">rbcli command --name<span style="color:#f92672">=</span>list
|
|
758
|
-
|
|
759
|
-
rbcli command -n list
|
|
760
|
-
</code></pre></div><p>A standard command can be identified by the presence of an <code>action</code> block in the definition:</p>
|
|
761
|
-
<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"><</span> <span style="color:#66d9ef">Rbcli</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Command</span>
|
|
762
|
-
action <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>params, args, global_opts, config<span style="color:#f92672">|</span>
|
|
763
|
-
<span style="color:#75715e"># Code goes here</span>
|
|
764
|
-
<span style="color:#66d9ef">end</span>
|
|
765
|
-
|
|
766
|
-
</code></pre></div><p>Your application’s <strong>parameters</strong>, <strong>arguments</strong>, <strong>options</strong>, and <strong>config</strong> are available in the variables passed into the block. For more information on these, see <a href="/rbcli/tutorial/40-options_parameters_and_arguments/">Options, Parameters, and Arguments</a>.</p>
|
|
757
|
+
<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>rbcli command --name<span style="color:#f92672">=</span>list
|
|
758
|
+
</span></span><span style="display:flex;"><span><span style="color:#75715e">#or</span>
|
|
759
|
+
</span></span><span style="display:flex;"><span>rbcli command -n list
|
|
760
|
+
</span></span></code></pre></div><p>A standard command can be identified by the presence of an <code>action</code> block in the definition:</p>
|
|
761
|
+
<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"><</span> <span style="color:#66d9ef">Rbcli</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Command</span>
|
|
762
|
+
</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>
|
|
763
|
+
</span></span><span style="display:flex;"><span> <span style="color:#75715e"># Code goes here</span>
|
|
764
|
+
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span>
|
|
765
|
+
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">end</span>
|
|
766
|
+
</span></span></code></pre></div><p>Your application’s <strong>parameters</strong>, <strong>arguments</strong>, <strong>options</strong>, and <strong>config</strong> are available in the variables passed into the block. For more information on these, see <a href="/rbcli/tutorial/40-options_parameters_and_arguments/">Options, Parameters, and Arguments</a>.</p>
|
|
767
767
|
<h2 id="scripted-commands">Scripted Commands</h2>
|
|
768
768
|
<p>Scripted commands are part Ruby, part Bash scripting. They are a good choice to use if you feel something might be easier or more performant to script with Bash, or if you already have a Bash script you’d like to use in your project. You can create one with:</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-bash" data-lang="bash">rbcli script -n list
|
|
770
|
-
</code></pre></div><p>This will create two files in your RBCli project: a Ruby file with the common command declaration (see <a href="#general-command-structure">General Command Structure</a>), and a bash script in the folder <code>application/commands/scripts/</code>.</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-bash" data-lang="bash"><span style="display:flex;"><span>rbcli script -n list
|
|
770
|
+
</span></span></code></pre></div><p>This will create two files in your RBCli project: a Ruby file with the common command declaration (see <a href="#general-command-structure">General Command Structure</a>), and a bash script in the folder <code>application/commands/scripts/</code>.</p>
|
|
771
771
|
<p>You can tell a command is a script by the line:</p>
|
|
772
|
-
<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"><</span> <span style="color:#66d9ef">Rbcli</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Command</span>
|
|
773
|
-
script
|
|
774
|
-
|
|
775
|
-
</code></pre></div><p>RBCli will pass along your applications config and CLI parameters through JSON environment variables. To make things easy, a Bash library is provided that makes retrieving and parsing these variables easy. It is already imported when you generate the command, with the line:</p>
|
|
776
|
-
<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">source <span style="color:#66d9ef">$(</span>echo <span style="color:#66d9ef">$(</span>cd <span style="color:#e6db74">"</span><span style="color:#66d9ef">$(</span>dirname <span style="color:#66d9ef">$(</span>gem which rbcli<span style="color:#66d9ef">))</span><span style="color:#e6db74">/../lib-sh"</span> <span style="color:#f92672">&&</span> pwd<span style="color:#66d9ef">)</span>/lib-rbcli.sh<span style="color:#66d9ef">)</span>
|
|
777
|
-
</code></pre></div><p>This will find the library which is stored on the system as part of the RBCli gem.</p>
|
|
772
|
+
<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"><</span> <span style="color:#66d9ef">Rbcli</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Command</span>
|
|
773
|
+
</span></span><span style="display:flex;"><span> script
|
|
774
|
+
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">end</span>
|
|
775
|
+
</span></span></code></pre></div><p>RBCli will pass along your applications config and CLI parameters through JSON environment variables. To make things easy, a Bash library is provided that makes retrieving and parsing these variables easy. It is already imported when you generate the command, with the line:</p>
|
|
776
|
+
<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>source <span style="color:#66d9ef">$(</span>echo <span style="color:#66d9ef">$(</span>cd <span style="color:#e6db74">"</span><span style="color:#66d9ef">$(</span>dirname <span style="color:#66d9ef">$(</span>gem which rbcli<span style="color:#66d9ef">))</span><span style="color:#e6db74">/../lib-sh"</span> <span style="color:#f92672">&&</span> pwd<span style="color:#66d9ef">)</span>/lib-rbcli.sh<span style="color:#66d9ef">)</span>
|
|
777
|
+
</span></span></code></pre></div><p>This will find the library which is stored on the system as part of the RBCli gem.</p>
|
|
778
778
|
<p>You can then retrieve the values present in your variables like such:</p>
|
|
779
|
-
<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">rbcli params
|
|
780
|
-
rbcli args
|
|
781
|
-
rbcli global_opts
|
|
782
|
-
rbcli config
|
|
783
|
-
rbcli myvars
|
|
784
|
-
|
|
785
|
-
echo <span style="color:#e6db74">"Usage Examples:"</span>
|
|
786
|
-
echo <span style="color:#e6db74">"Log Level: </span><span style="color:#66d9ef">$(</span>rbcli config .logger.log_level<span style="color:#66d9ef">)</span><span style="color:#e6db74">"</span>
|
|
787
|
-
echo <span style="color:#e6db74">"Log Target: </span><span style="color:#66d9ef">$(</span>rbcli config .logger.log_target<span style="color:#66d9ef">)</span><span style="color:#e6db74">"</span>
|
|
788
|
-
echo <span style="color:#e6db74">"First Argument (if passed): </span><span style="color:#66d9ef">$(</span>rbcli args .<span style="color:#f92672">[</span>0<span style="color:#f92672">]</span><span style="color:#66d9ef">)</span><span style="color:#e6db74">"</span>
|
|
789
|
-
</code></pre></div><p>For your convenience, the script will have all the instructions needed there. For more instructions on how to use JQ syntax to parse values, see the <a href="https://stedolan.github.io/jq/manual/">JQ documentation</a>.</p>
|
|
779
|
+
<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>rbcli params
|
|
780
|
+
</span></span><span style="display:flex;"><span>rbcli args
|
|
781
|
+
</span></span><span style="display:flex;"><span>rbcli global_opts
|
|
782
|
+
</span></span><span style="display:flex;"><span>rbcli config
|
|
783
|
+
</span></span><span style="display:flex;"><span>rbcli myvars
|
|
784
|
+
</span></span><span style="display:flex;"><span>
|
|
785
|
+
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">"Usage Examples:"</span>
|
|
786
|
+
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">"Log Level: </span><span style="color:#66d9ef">$(</span>rbcli config .logger.log_level<span style="color:#66d9ef">)</span><span style="color:#e6db74">"</span>
|
|
787
|
+
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">"Log Target: </span><span style="color:#66d9ef">$(</span>rbcli config .logger.log_target<span style="color:#66d9ef">)</span><span style="color:#e6db74">"</span>
|
|
788
|
+
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">"First Argument (if passed): </span><span style="color:#66d9ef">$(</span>rbcli args .<span style="color:#f92672">[</span>0<span style="color:#f92672">]</span><span style="color:#66d9ef">)</span><span style="color:#e6db74">"</span>
|
|
789
|
+
</span></span></code></pre></div><p>For your convenience, the script will have all the instructions needed there. For more instructions on how to use JQ syntax to parse values, see the <a href="https://stedolan.github.io/jq/manual/">JQ documentation</a>.</p>
|
|
790
790
|
<h2 id="external-commands">External Commands</h2>
|
|
791
791
|
<p>External Commands are used to wrap 3rd party applications. RBCli accomplishes this by allowing you to set environment variables and command line parameters based on your input variables.</p>
|
|
792
792
|
<p>RBCli provides this feature through the <code>extern</code> keyword. It provides two modes – <strong>direct path</strong> and <strong>variable path</strong> – which work similarly.</p>
|
|
793
793
|
<h3 id="direct-path-mode">Direct Path Mode</h3>
|
|
794
794
|
<p>Direct path mode is the simpler mode of the two External Command modes. It allows you to provide a specific command with environment variables set, though it does not allow using RBCli parameters, arguments, options, and config.</p>
|
|
795
|
-
<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"><</span> <span style="color:#66d9ef">Rbcli</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Command</span>
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
</code></pre></div><p>Here, we supply a string to run the command. We can optioanlly provide environment variables which will be set for the external application.</p>
|
|
795
|
+
<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"><</span> <span style="color:#66d9ef">Rbcli</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Command</span>
|
|
796
|
+
</span></span><span style="display:flex;"><span> extern <span style="color:#e6db74">path</span>: <span style="color:#e6db74">'path/to/application'</span>, <span style="color:#e6db74">envvars</span>: {<span style="color:#e6db74">MYVAR</span>: <span style="color:#e6db74">'some_value'</span>} <span style="color:#75715e"># (Required) Runs a given application, with optional environment variables, when the user runs the command.</span>
|
|
797
|
+
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">end</span>
|
|
798
|
+
</span></span></code></pre></div><p>Here, we supply a string to run the command. We can optioanlly provide environment variables which will be set for the external application.</p>
|
|
799
799
|
<h3 id="variable-path-mode">Variable Path Mode</h3>
|
|
800
800
|
<p>Variable Path mode works the same as Direct Path Mode, only instead of providing a string we provide a block that returns a string (which will be the command executed). This allows us to generate different commands based on the CLI parameters that the user passed, or pass configuration as CLI parameters to the external application:</p>
|
|
801
|
-
<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">Test</span> <span style="color:#f92672"><</span> <span style="color:#66d9ef">Rbcli</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Command</span>
|
|
802
|
-
extern <span style="color:#e6db74">envvars</span>: {<span style="color:#e6db74">MY_OTHER_VAR</span>: <span style="color:#e6db74">'another_value'</span>} <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"># Alternate usage. Supplying a block instead of a path allows us to modify the command based on the arguments and configuration supplied by the user. This allows passing config settings as command line arguments to external applications. The block must return a string, which is the command to be executed.</span>
|
|
803
|
-
cmd <span style="color:#f92672">=</span> <span style="color:#e6db74">'/path/to/application'</span>
|
|
804
|
-
cmd <span style="color:#f92672">+=</span> <span style="color:#e6db74">' --test-script foo --ignore-errors'</span> <span style="color:#66d9ef">if</span> params<span style="color:#f92672">[</span><span style="color:#e6db74">:force</span><span style="color:#f92672">]</span>
|
|
805
|
-
cmd
|
|
806
|
-
<span style="color:#66d9ef">end</span>
|
|
807
|
-
|
|
808
|
-
</code></pre></div><p><strong>NOTE</strong>: Passing user-supplied data as part of the command string may be a security risk (example: <code>/path/to/application --name #{params[:name]}</code>). It is highly recommended to provide the fixed strings yourself, and only select which strings are used based on the variables provided. This is demonstrated in the example above.</p>
|
|
801
|
+
<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">Test</span> <span style="color:#f92672"><</span> <span style="color:#66d9ef">Rbcli</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Command</span>
|
|
802
|
+
</span></span><span style="display:flex;"><span> extern <span style="color:#e6db74">envvars</span>: {<span style="color:#e6db74">MY_OTHER_VAR</span>: <span style="color:#e6db74">'another_value'</span>} <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"># Alternate usage. Supplying a block instead of a path allows us to modify the command based on the arguments and configuration supplied by the user. This allows passing config settings as command line arguments to external applications. The block must return a string, which is the command to be executed.</span>
|
|
803
|
+
</span></span><span style="display:flex;"><span> cmd <span style="color:#f92672">=</span> <span style="color:#e6db74">'/path/to/application'</span>
|
|
804
|
+
</span></span><span style="display:flex;"><span> cmd <span style="color:#f92672">+=</span> <span style="color:#e6db74">' --test-script foo --ignore-errors'</span> <span style="color:#66d9ef">if</span> params<span style="color:#f92672">[</span><span style="color:#e6db74">:force</span><span style="color:#f92672">]</span>
|
|
805
|
+
</span></span><span style="display:flex;"><span> cmd
|
|
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>
|
|
808
|
+
</span></span></code></pre></div><p><strong>NOTE</strong>: Passing user-supplied data as part of the command string may be a security risk (example: <code>/path/to/application --name #{params[:name]}</code>). It is highly recommended to provide the fixed strings yourself, and only select which strings are used based on the variables provided. This is demonstrated in the example above.</p>
|
|
809
809
|
|
|
810
810
|
|
|
811
811
|
<footer class="footline">
|
|
@@ -1239,19 +1239,19 @@ echo <span style="color:#e6db74">"First Argument (if passed): </span><span s
|
|
|
1239
1239
|
<div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
|
|
1240
1240
|
<div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
|
|
1241
1241
|
</div>
|
|
1242
|
-
<script src="/rbcli/js/clipboard.min.js?
|
|
1243
|
-
<script src="/rbcli/js/perfect-scrollbar.min.js?
|
|
1244
|
-
<script src="/rbcli/js/perfect-scrollbar.jquery.min.js?
|
|
1245
|
-
<script src="/rbcli/js/jquery.sticky.js?
|
|
1246
|
-
<script src="/rbcli/js/featherlight.min.js?
|
|
1247
|
-
<script src="/rbcli/js/highlight.pack.js?
|
|
1242
|
+
<script src="/rbcli/js/clipboard.min.js?1713907739"></script>
|
|
1243
|
+
<script src="/rbcli/js/perfect-scrollbar.min.js?1713907739"></script>
|
|
1244
|
+
<script src="/rbcli/js/perfect-scrollbar.jquery.min.js?1713907739"></script>
|
|
1245
|
+
<script src="/rbcli/js/jquery.sticky.js?1713907739"></script>
|
|
1246
|
+
<script src="/rbcli/js/featherlight.min.js?1713907739"></script>
|
|
1247
|
+
<script src="/rbcli/js/highlight.pack.js?1713907739"></script>
|
|
1248
1248
|
<script>hljs.initHighlightingOnLoad();</script>
|
|
1249
|
-
<script src="/rbcli/js/modernizr.custom-3.6.0.js?
|
|
1250
|
-
<script src="/rbcli/js/learn.js?
|
|
1251
|
-
<script src="/rbcli/js/hugo-learn.js?
|
|
1249
|
+
<script src="/rbcli/js/modernizr.custom-3.6.0.js?1713907739"></script>
|
|
1250
|
+
<script src="/rbcli/js/learn.js?1713907739"></script>
|
|
1251
|
+
<script src="/rbcli/js/hugo-learn.js?1713907739"></script>
|
|
1252
1252
|
|
|
1253
|
-
<link href="/rbcli/mermaid/mermaid.css?
|
|
1254
|
-
<script src="/rbcli/mermaid/mermaid.js?
|
|
1253
|
+
<link href="/rbcli/mermaid/mermaid.css?1713907739" rel="stylesheet" />
|
|
1254
|
+
<script src="/rbcli/mermaid/mermaid.js?1713907739"></script>
|
|
1255
1255
|
<script>
|
|
1256
1256
|
mermaid.initialize({ startOnLoad: true });
|
|
1257
1257
|
</script>
|
|
@@ -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.
|
|
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>Distributed State and Locking :: RBCli Documentation</title>
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
<link href="/rbcli/css/nucleus.css?
|
|
16
|
-
<link href="/rbcli/css/fontawesome-all.min.css?
|
|
17
|
-
<link href="/rbcli/css/hybrid.css?
|
|
18
|
-
<link href="/rbcli/css/featherlight.min.css?
|
|
19
|
-
<link href="/rbcli/css/perfect-scrollbar.min.css?
|
|
20
|
-
<link href="/rbcli/css/auto-complete.css?
|
|
21
|
-
<link href="/rbcli/css/atom-one-dark-reasonable.css?
|
|
22
|
-
<link href="/rbcli/css/theme.css?
|
|
23
|
-
<link href="/rbcli/css/hugo-theme.css?
|
|
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?
|
|
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?
|
|
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?
|
|
59
|
-
<script type="text/javascript" src="/rbcli/js/auto-complete.js?
|
|
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?
|
|
65
|
+
<script type="text/javascript" src="/rbcli/js/search.js?1713907739"></script>
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
</div>
|
|
@@ -716,10 +716,10 @@
|
|
|
716
716
|
</ol>
|
|
717
717
|
<h2 id="manual-locking">Manual Locking</h2>
|
|
718
718
|
<p>Remember: all state in Rbcli is lazy-loaded. Therefore, RBCli wll only attempt to lock the data when you first try to access it. If you need to make sure that the data is locked before executing a block of code, use:</p>
|
|
719
|
-
<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">Rbcli</span><span style="color:#f92672">.</span>remote_state<span style="color:#f92672">.</span>refresh
|
|
720
|
-
</code></pre></div><p>to force the lock and retrieve the latest data. You can force an unlock by calling:</p>
|
|
721
|
-
<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">Rbcli</span><span style="color:#f92672">.</span>remote_state<span style="color:#f92672">.</span>disconnect
|
|
722
|
-
</code></pre></div><p>Even if you do not want to store any data, you can leverage manual locking to control access to a different shared resource, such as a stateful API. For example, if you write a cloud deployment toolkit, you can ensure that only one user is attempting to modify a deployment at any given time.</p>
|
|
719
|
+
<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">Rbcli</span><span style="color:#f92672">.</span>remote_state<span style="color:#f92672">.</span>refresh
|
|
720
|
+
</span></span></code></pre></div><p>to force the lock and retrieve the latest data. You can force an unlock by calling:</p>
|
|
721
|
+
<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">Rbcli</span><span style="color:#f92672">.</span>remote_state<span style="color:#f92672">.</span>disconnect
|
|
722
|
+
</span></span></code></pre></div><p>Even if you do not want to store any data, you can leverage manual locking to control access to a different shared resource, such as a stateful API. For example, if you write a cloud deployment toolkit, you can ensure that only one user is attempting to modify a deployment at any given time.</p>
|
|
723
723
|
|
|
724
724
|
|
|
725
725
|
<footer class="footline">
|
|
@@ -1153,19 +1153,19 @@
|
|
|
1153
1153
|
<div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
|
|
1154
1154
|
<div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
|
|
1155
1155
|
</div>
|
|
1156
|
-
<script src="/rbcli/js/clipboard.min.js?
|
|
1157
|
-
<script src="/rbcli/js/perfect-scrollbar.min.js?
|
|
1158
|
-
<script src="/rbcli/js/perfect-scrollbar.jquery.min.js?
|
|
1159
|
-
<script src="/rbcli/js/jquery.sticky.js?
|
|
1160
|
-
<script src="/rbcli/js/featherlight.min.js?
|
|
1161
|
-
<script src="/rbcli/js/highlight.pack.js?
|
|
1156
|
+
<script src="/rbcli/js/clipboard.min.js?1713907739"></script>
|
|
1157
|
+
<script src="/rbcli/js/perfect-scrollbar.min.js?1713907739"></script>
|
|
1158
|
+
<script src="/rbcli/js/perfect-scrollbar.jquery.min.js?1713907739"></script>
|
|
1159
|
+
<script src="/rbcli/js/jquery.sticky.js?1713907739"></script>
|
|
1160
|
+
<script src="/rbcli/js/featherlight.min.js?1713907739"></script>
|
|
1161
|
+
<script src="/rbcli/js/highlight.pack.js?1713907739"></script>
|
|
1162
1162
|
<script>hljs.initHighlightingOnLoad();</script>
|
|
1163
|
-
<script src="/rbcli/js/modernizr.custom-3.6.0.js?
|
|
1164
|
-
<script src="/rbcli/js/learn.js?
|
|
1165
|
-
<script src="/rbcli/js/hugo-learn.js?
|
|
1163
|
+
<script src="/rbcli/js/modernizr.custom-3.6.0.js?1713907739"></script>
|
|
1164
|
+
<script src="/rbcli/js/learn.js?1713907739"></script>
|
|
1165
|
+
<script src="/rbcli/js/hugo-learn.js?1713907739"></script>
|
|
1166
1166
|
|
|
1167
|
-
<link href="/rbcli/mermaid/mermaid.css?
|
|
1168
|
-
<script src="/rbcli/mermaid/mermaid.js?
|
|
1167
|
+
<link href="/rbcli/mermaid/mermaid.css?1713907739" rel="stylesheet" />
|
|
1168
|
+
<script src="/rbcli/mermaid/mermaid.js?1713907739"></script>
|
|
1169
1169
|
<script>
|
|
1170
1170
|
mermaid.initialize({ startOnLoad: true });
|
|
1171
1171
|
</script>
|
|
@@ -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.
|
|
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>Execution Hooks :: RBCli Documentation</title>
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
<link href="/rbcli/css/nucleus.css?
|
|
16
|
-
<link href="/rbcli/css/fontawesome-all.min.css?
|
|
17
|
-
<link href="/rbcli/css/hybrid.css?
|
|
18
|
-
<link href="/rbcli/css/featherlight.min.css?
|
|
19
|
-
<link href="/rbcli/css/perfect-scrollbar.min.css?
|
|
20
|
-
<link href="/rbcli/css/auto-complete.css?
|
|
21
|
-
<link href="/rbcli/css/atom-one-dark-reasonable.css?
|
|
22
|
-
<link href="/rbcli/css/theme.css?
|
|
23
|
-
<link href="/rbcli/css/hugo-theme.css?
|
|
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?
|
|
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?
|
|
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?
|
|
59
|
-
<script type="text/javascript" src="/rbcli/js/auto-complete.js?
|
|
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?
|
|
65
|
+
<script type="text/javascript" src="/rbcli/js/search.js?1713907739"></script>
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
</div>
|
|
@@ -711,31 +711,31 @@
|
|
|
711
711
|
<h2 id="the-defailt-action-hook">The Defailt Action Hook</h2>
|
|
712
712
|
<p>The Default hook is called when a user calls your application without providing a command. If the hook is not provided, the application will automatically display the help text (the same as running it with <code>-h</code>).</p>
|
|
713
713
|
<p>To create it in your project, run:</p>
|
|
714
|
-
<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">rbcli hook --default
|
|
715
|
-
|
|
716
|
-
rbcli hook -d
|
|
717
|
-
</code></pre></div><p>You will then find the hook under <code>hooks/default_action.rb</code>.</p>
|
|
714
|
+
<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>rbcli hook --default
|
|
715
|
+
</span></span><span style="display:flex;"><span><span style="color:#75715e"># or</span>
|
|
716
|
+
</span></span><span style="display:flex;"><span>rbcli hook -d
|
|
717
|
+
</span></span></code></pre></div><p>You will then find the hook under <code>hooks/default_action.rb</code>.</p>
|
|
718
718
|
<h2 id="the-pre-execution-hook">The Pre-Execution Hook</h2>
|
|
719
719
|
<p>The Pre-Execution hook is called after the global command line options are parsed and before a command is executed.</p>
|
|
720
720
|
<p>To create it in your project, run:</p>
|
|
721
|
-
<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">rbcli hook --pre
|
|
722
|
-
|
|
723
|
-
rbcli hook -p
|
|
724
|
-
</code></pre></div><p>You will then find the hook under <code>hooks/pre_execution.rb</code>.</p>
|
|
721
|
+
<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>rbcli hook --pre
|
|
722
|
+
</span></span><span style="display:flex;"><span><span style="color:#75715e"># or</span>
|
|
723
|
+
</span></span><span style="display:flex;"><span>rbcli hook -p
|
|
724
|
+
</span></span></code></pre></div><p>You will then find the hook under <code>hooks/pre_execution.rb</code>.</p>
|
|
725
725
|
<h2 id="the-post-execution-hook">The Post-Execution Hook</h2>
|
|
726
726
|
<p>The Pre-Execution hook is called after a command is executed.</p>
|
|
727
727
|
<p>To create it in your project, run:</p>
|
|
728
|
-
<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">rbcli hook --post
|
|
729
|
-
|
|
730
|
-
rbcli hook -o
|
|
731
|
-
</code></pre></div><p>You will then find the hook under <code>hooks/post_execution.rb</code>.</p>
|
|
728
|
+
<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>rbcli hook --post
|
|
729
|
+
</span></span><span style="display:flex;"><span><span style="color:#75715e"># or</span>
|
|
730
|
+
</span></span><span style="display:flex;"><span>rbcli hook -o
|
|
731
|
+
</span></span></code></pre></div><p>You will then find the hook under <code>hooks/post_execution.rb</code>.</p>
|
|
732
732
|
<h2 id="the-first-run-hook">The First-Run Hook</h2>
|
|
733
733
|
<p>The First-Run hook is called the first time a user executes your application. Using the first-run hook requires enabling <a href="/rbcli/advanced/state_storage/">Local State Storage</a> for persistence.</p>
|
|
734
734
|
<p>To create it in your project, run:</p>
|
|
735
|
-
<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">rbcli hook --firstrun
|
|
736
|
-
|
|
737
|
-
rbcli hook -f
|
|
738
|
-
</code></pre></div><p>You will then find the hook under <code>hooks/first_run.rb</code>.</p>
|
|
735
|
+
<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>rbcli hook --firstrun
|
|
736
|
+
</span></span><span style="display:flex;"><span><span style="color:#75715e"># or</span>
|
|
737
|
+
</span></span><span style="display:flex;"><span>rbcli hook -f
|
|
738
|
+
</span></span></code></pre></div><p>You will then find the hook under <code>hooks/first_run.rb</code>.</p>
|
|
739
739
|
|
|
740
740
|
|
|
741
741
|
<footer class="footline">
|
|
@@ -1169,19 +1169,19 @@ rbcli hook -f
|
|
|
1169
1169
|
<div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
|
|
1170
1170
|
<div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
|
|
1171
1171
|
</div>
|
|
1172
|
-
<script src="/rbcli/js/clipboard.min.js?
|
|
1173
|
-
<script src="/rbcli/js/perfect-scrollbar.min.js?
|
|
1174
|
-
<script src="/rbcli/js/perfect-scrollbar.jquery.min.js?
|
|
1175
|
-
<script src="/rbcli/js/jquery.sticky.js?
|
|
1176
|
-
<script src="/rbcli/js/featherlight.min.js?
|
|
1177
|
-
<script src="/rbcli/js/highlight.pack.js?
|
|
1172
|
+
<script src="/rbcli/js/clipboard.min.js?1713907739"></script>
|
|
1173
|
+
<script src="/rbcli/js/perfect-scrollbar.min.js?1713907739"></script>
|
|
1174
|
+
<script src="/rbcli/js/perfect-scrollbar.jquery.min.js?1713907739"></script>
|
|
1175
|
+
<script src="/rbcli/js/jquery.sticky.js?1713907739"></script>
|
|
1176
|
+
<script src="/rbcli/js/featherlight.min.js?1713907739"></script>
|
|
1177
|
+
<script src="/rbcli/js/highlight.pack.js?1713907739"></script>
|
|
1178
1178
|
<script>hljs.initHighlightingOnLoad();</script>
|
|
1179
|
-
<script src="/rbcli/js/modernizr.custom-3.6.0.js?
|
|
1180
|
-
<script src="/rbcli/js/learn.js?
|
|
1181
|
-
<script src="/rbcli/js/hugo-learn.js?
|
|
1179
|
+
<script src="/rbcli/js/modernizr.custom-3.6.0.js?1713907739"></script>
|
|
1180
|
+
<script src="/rbcli/js/learn.js?1713907739"></script>
|
|
1181
|
+
<script src="/rbcli/js/hugo-learn.js?1713907739"></script>
|
|
1182
1182
|
|
|
1183
|
-
<link href="/rbcli/mermaid/mermaid.css?
|
|
1184
|
-
<script src="/rbcli/mermaid/mermaid.js?
|
|
1183
|
+
<link href="/rbcli/mermaid/mermaid.css?1713907739" rel="stylesheet" />
|
|
1184
|
+
<script src="/rbcli/mermaid/mermaid.js?1713907739"></script>
|
|
1185
1185
|
<script>
|
|
1186
1186
|
mermaid.initialize({ startOnLoad: true });
|
|
1187
1187
|
</script>
|