rbcli 0.2.2 → 0.2.4
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 +14 -0
- data/Gemfile.lock +2 -2
- data/README.md +6 -1
- data/docs-src/docs/advanced/interactive_commands.md +37 -0
- data/docs-src/docs/imported/changelog.md +14 -0
- data/docs-src/docs/tutorial/40-options_parameters_and_arguments.md +25 -0
- data/docs-src/makesite.sh +1 -1
- data/docs-src/mkdocs.yml +3 -1
- data/docs/404.html +36 -12
- data/docs/advanced/automatic_updates/index.html +36 -12
- data/docs/advanced/command_types/index.html +34 -10
- data/docs/advanced/distributed_state_locking/index.html +34 -10
- data/docs/advanced/hooks/index.html +36 -12
- data/docs/advanced/interactive_commands/index.html +829 -0
- data/docs/advanced/logging/index.html +833 -0
- data/docs/advanced/remote_execution/index.html +36 -12
- data/docs/advanced/state_storage/index.html +34 -10
- data/docs/advanced/user_config_files/index.html +34 -10
- data/docs/assets/javascripts/application.583bbe55.js +1 -0
- data/docs/assets/stylesheets/application-palette.22915126.css +1176 -0
- data/docs/assets/stylesheets/application.451f80e5.css +2552 -0
- data/docs/development/code_of_conduct/index.html +34 -10
- data/docs/development/contributing/index.html +36 -12
- data/docs/development/license/index.html +34 -10
- data/docs/imported/changelog/index.html +132 -27
- data/docs/imported/quick_reference/index.html +34 -10
- data/docs/index.html +36 -12
- data/docs/search/search_index.json +1 -639
- data/docs/sitemap.xml +48 -38
- data/docs/sitemap.xml.gz +0 -0
- data/docs/tutorial/10-getting_started/index.html +34 -10
- data/docs/tutorial/20-project_layout/index.html +34 -10
- data/docs/tutorial/30-your_first_command/index.html +34 -10
- data/docs/tutorial/40-options_parameters_and_arguments/index.html +75 -10
- data/docs/tutorial/50-publishing/index.html +34 -10
- data/docs/whoami/index.html +36 -12
- data/exe/rbcli +1 -1
- data/lib/rbcli/engine/command.rb +28 -2
- data/lib/rbcli/version.rb +1 -1
- data/rbcli.gemspec +1 -1
- data/skeletons/project/application/commands/command.erb +1 -1
- metadata +10 -6
- data/docs/assets/javascripts/application.a59e2a89.js +0 -1
- data/docs/assets/stylesheets/application-palette.6079476c.css +0 -2
- data/docs/assets/stylesheets/application.ba0fd1a6.css +0 -2
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
<meta name="lang:search.tokenizer" content="[\s\-]+">
|
|
37
37
|
|
|
38
38
|
<link rel="shortcut icon" href="../../assets/images/favicon.png">
|
|
39
|
-
<meta name="generator" content="mkdocs-0.
|
|
39
|
+
<meta name="generator" content="mkdocs-1.0.3, mkdocs-material-3.0.4">
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
<link rel="stylesheet" href="../../assets/stylesheets/application.
|
|
47
|
+
<link rel="stylesheet" href="../../assets/stylesheets/application.451f80e5.css">
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
<script src="../../assets/javascripts/modernizr.1aa3b519.js"></script>
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
<link href="https://fonts.gstatic.com" rel="preconnect" crossorigin>
|
|
56
55
|
|
|
56
|
+
<link href="https://fonts.gstatic.com" rel="preconnect" crossorigin>
|
|
57
57
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono">
|
|
58
58
|
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
|
|
59
59
|
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
|
|
95
95
|
<label class="md-overlay" data-md-component="overlay" for="__drawer"></label>
|
|
96
96
|
|
|
97
|
-
<a href="
|
|
97
|
+
<a href="../../#options-paramters-and-arguments" tabindex="1" class="md-skip">
|
|
98
98
|
Skip to content
|
|
99
99
|
</a>
|
|
100
100
|
|
|
@@ -264,11 +264,11 @@
|
|
|
264
264
|
<div class="md-sidebar__inner">
|
|
265
265
|
<nav class="md-nav md-nav--primary" data-md-level="0">
|
|
266
266
|
<label class="md-nav__title md-nav__title--site" for="__drawer">
|
|
267
|
-
<
|
|
267
|
+
<a href="../.." title="RBCli Documentation" class="md-nav__button md-logo">
|
|
268
268
|
|
|
269
269
|
<i class="md-icon">devices</i>
|
|
270
270
|
|
|
271
|
-
</
|
|
271
|
+
</a>
|
|
272
272
|
RBCli Documentation
|
|
273
273
|
</label>
|
|
274
274
|
|
|
@@ -428,6 +428,19 @@
|
|
|
428
428
|
Parameters
|
|
429
429
|
</a>
|
|
430
430
|
|
|
431
|
+
<nav class="md-nav">
|
|
432
|
+
<ul class="md-nav__list">
|
|
433
|
+
|
|
434
|
+
<li class="md-nav__item">
|
|
435
|
+
<a href="#user-prompting" title="User Prompting" class="md-nav__link">
|
|
436
|
+
User Prompting
|
|
437
|
+
</a>
|
|
438
|
+
|
|
439
|
+
</li>
|
|
440
|
+
|
|
441
|
+
</ul>
|
|
442
|
+
</nav>
|
|
443
|
+
|
|
431
444
|
</li>
|
|
432
445
|
|
|
433
446
|
<li class="md-nav__item">
|
|
@@ -539,6 +552,18 @@
|
|
|
539
552
|
|
|
540
553
|
|
|
541
554
|
|
|
555
|
+
<li class="md-nav__item">
|
|
556
|
+
<a href="../../advanced/logging/" title="Logging" class="md-nav__link">
|
|
557
|
+
Logging
|
|
558
|
+
</a>
|
|
559
|
+
</li>
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
|
|
542
567
|
<li class="md-nav__item">
|
|
543
568
|
<a href="../../advanced/automatic_updates/" title="Automatic Updates" class="md-nav__link">
|
|
544
569
|
Automatic Updates
|
|
@@ -582,6 +607,18 @@
|
|
|
582
607
|
</li>
|
|
583
608
|
|
|
584
609
|
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
<li class="md-nav__item">
|
|
616
|
+
<a href="../../advanced/interactive_commands/" title="Interactive Commands" class="md-nav__link">
|
|
617
|
+
Interactive Commands
|
|
618
|
+
</a>
|
|
619
|
+
</li>
|
|
620
|
+
|
|
621
|
+
|
|
585
622
|
</ul>
|
|
586
623
|
</nav>
|
|
587
624
|
</li>
|
|
@@ -665,8 +702,8 @@
|
|
|
665
702
|
|
|
666
703
|
|
|
667
704
|
<li class="md-nav__item">
|
|
668
|
-
<a href="../../whoami/" title="
|
|
669
|
-
|
|
705
|
+
<a href="../../whoami/" title="whoami" class="md-nav__link">
|
|
706
|
+
whoami
|
|
670
707
|
</a>
|
|
671
708
|
</li>
|
|
672
709
|
|
|
@@ -710,6 +747,19 @@
|
|
|
710
747
|
Parameters
|
|
711
748
|
</a>
|
|
712
749
|
|
|
750
|
+
<nav class="md-nav">
|
|
751
|
+
<ul class="md-nav__list">
|
|
752
|
+
|
|
753
|
+
<li class="md-nav__item">
|
|
754
|
+
<a href="#user-prompting" title="User Prompting" class="md-nav__link">
|
|
755
|
+
User Prompting
|
|
756
|
+
</a>
|
|
757
|
+
|
|
758
|
+
</li>
|
|
759
|
+
|
|
760
|
+
</ul>
|
|
761
|
+
</nav>
|
|
762
|
+
|
|
713
763
|
</li>
|
|
714
764
|
|
|
715
765
|
<li class="md-nav__item">
|
|
@@ -867,6 +917,21 @@ parameter :directoriesfirst, 'Show directories on top', type: :boolean, default:
|
|
|
867
917
|
</code></pre>
|
|
868
918
|
|
|
869
919
|
<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>
|
|
920
|
+
<h3 id="user-prompting">User Prompting</h3>
|
|
921
|
+
<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's change one of our parameters to utilize it:</p>
|
|
922
|
+
<pre><code class="ruby">parameter :sort, 'Sort output alphabetically', type: :boolean, default: false, prompt: "Sort output alphabetically?"
|
|
923
|
+
</code></pre>
|
|
924
|
+
|
|
925
|
+
<p>Now, let's run the tool while omitting the <code>--sort</code> parameter, as such:</p>
|
|
926
|
+
<pre><code class="bash">mytool -c list -ad
|
|
927
|
+
</code></pre>
|
|
928
|
+
|
|
929
|
+
<p>This should give you the prompt:</p>
|
|
930
|
+
<pre><code>Sort output alphabetically? (y/N):
|
|
931
|
+
</code></pre>
|
|
932
|
+
|
|
933
|
+
<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>
|
|
934
|
+
<p>For more information, see the documentation on <a href="../../advanced/interactive_commands/">Interactive Commands</a>.</p>
|
|
870
935
|
<h2 id="arguments">Arguments</h2>
|
|
871
936
|
<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's take a look at how we can use them.</p>
|
|
872
937
|
<p>Unlike options and parameters, arguments require no setup. So let'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't listed automatically by the help function, this is a good example of what to put in your usage text. Let's take a look at what our class looks like now:</p>
|
|
@@ -1049,9 +1114,9 @@ parameter :<name>, "<description_string>", short: '<cha
|
|
|
1049
1114
|
|
|
1050
1115
|
</div>
|
|
1051
1116
|
|
|
1052
|
-
<script src="../../assets/javascripts/application.
|
|
1117
|
+
<script src="../../assets/javascripts/application.583bbe55.js"></script>
|
|
1053
1118
|
|
|
1054
|
-
<script>app.initialize({version:"0.
|
|
1119
|
+
<script>app.initialize({version:"1.0.3",url:{base:"../.."}})</script>
|
|
1055
1120
|
|
|
1056
1121
|
|
|
1057
1122
|
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
<meta name="lang:search.tokenizer" content="[\s\-]+">
|
|
37
37
|
|
|
38
38
|
<link rel="shortcut icon" href="../../assets/images/favicon.png">
|
|
39
|
-
<meta name="generator" content="mkdocs-0.
|
|
39
|
+
<meta name="generator" content="mkdocs-1.0.3, mkdocs-material-3.0.4">
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
<link rel="stylesheet" href="../../assets/stylesheets/application.
|
|
47
|
+
<link rel="stylesheet" href="../../assets/stylesheets/application.451f80e5.css">
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
<script src="../../assets/javascripts/modernizr.1aa3b519.js"></script>
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
<link href="https://fonts.gstatic.com" rel="preconnect" crossorigin>
|
|
56
55
|
|
|
56
|
+
<link href="https://fonts.gstatic.com" rel="preconnect" crossorigin>
|
|
57
57
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono">
|
|
58
58
|
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
|
|
59
59
|
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
|
|
95
95
|
<label class="md-overlay" data-md-component="overlay" for="__drawer"></label>
|
|
96
96
|
|
|
97
|
-
<a href="
|
|
97
|
+
<a href="../../#publishing-your-application" tabindex="1" class="md-skip">
|
|
98
98
|
Skip to content
|
|
99
99
|
</a>
|
|
100
100
|
|
|
@@ -264,11 +264,11 @@
|
|
|
264
264
|
<div class="md-sidebar__inner">
|
|
265
265
|
<nav class="md-nav md-nav--primary" data-md-level="0">
|
|
266
266
|
<label class="md-nav__title md-nav__title--site" for="__drawer">
|
|
267
|
-
<
|
|
267
|
+
<a href="../.." title="RBCli Documentation" class="md-nav__button md-logo">
|
|
268
268
|
|
|
269
269
|
<i class="md-icon">devices</i>
|
|
270
270
|
|
|
271
|
-
</
|
|
271
|
+
</a>
|
|
272
272
|
RBCli Documentation
|
|
273
273
|
</label>
|
|
274
274
|
|
|
@@ -532,6 +532,18 @@
|
|
|
532
532
|
|
|
533
533
|
|
|
534
534
|
|
|
535
|
+
<li class="md-nav__item">
|
|
536
|
+
<a href="../../advanced/logging/" title="Logging" class="md-nav__link">
|
|
537
|
+
Logging
|
|
538
|
+
</a>
|
|
539
|
+
</li>
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
535
547
|
<li class="md-nav__item">
|
|
536
548
|
<a href="../../advanced/automatic_updates/" title="Automatic Updates" class="md-nav__link">
|
|
537
549
|
Automatic Updates
|
|
@@ -575,6 +587,18 @@
|
|
|
575
587
|
</li>
|
|
576
588
|
|
|
577
589
|
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
<li class="md-nav__item">
|
|
596
|
+
<a href="../../advanced/interactive_commands/" title="Interactive Commands" class="md-nav__link">
|
|
597
|
+
Interactive Commands
|
|
598
|
+
</a>
|
|
599
|
+
</li>
|
|
600
|
+
|
|
601
|
+
|
|
578
602
|
</ul>
|
|
579
603
|
</nav>
|
|
580
604
|
</li>
|
|
@@ -658,8 +682,8 @@
|
|
|
658
682
|
|
|
659
683
|
|
|
660
684
|
<li class="md-nav__item">
|
|
661
|
-
<a href="../../whoami/" title="
|
|
662
|
-
|
|
685
|
+
<a href="../../whoami/" title="whoami" class="md-nav__link">
|
|
686
|
+
whoami
|
|
663
687
|
</a>
|
|
664
688
|
</li>
|
|
665
689
|
|
|
@@ -838,9 +862,9 @@ gem install mytool-*.gem
|
|
|
838
862
|
|
|
839
863
|
</div>
|
|
840
864
|
|
|
841
|
-
<script src="../../assets/javascripts/application.
|
|
865
|
+
<script src="../../assets/javascripts/application.583bbe55.js"></script>
|
|
842
866
|
|
|
843
|
-
<script>app.initialize({version:"0.
|
|
867
|
+
<script>app.initialize({version:"1.0.3",url:{base:"../.."}})</script>
|
|
844
868
|
|
|
845
869
|
|
|
846
870
|
|
data/docs/whoami/index.html
CHANGED
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
<meta name="lang:search.tokenizer" content="[\s\-]+">
|
|
37
37
|
|
|
38
38
|
<link rel="shortcut icon" href="../assets/images/favicon.png">
|
|
39
|
-
<meta name="generator" content="mkdocs-0.
|
|
39
|
+
<meta name="generator" content="mkdocs-1.0.3, mkdocs-material-3.0.4">
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
<title
|
|
43
|
+
<title>whoami - RBCli Documentation</title>
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
<link rel="stylesheet" href="../assets/stylesheets/application.
|
|
47
|
+
<link rel="stylesheet" href="../assets/stylesheets/application.451f80e5.css">
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
<script src="../assets/javascripts/modernizr.1aa3b519.js"></script>
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
<link href="https://fonts.gstatic.com" rel="preconnect" crossorigin>
|
|
56
55
|
|
|
56
|
+
<link href="https://fonts.gstatic.com" rel="preconnect" crossorigin>
|
|
57
57
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono">
|
|
58
58
|
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
|
|
59
59
|
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
|
|
95
95
|
<label class="md-overlay" data-md-component="overlay" for="__drawer"></label>
|
|
96
96
|
|
|
97
|
-
<a href="
|
|
97
|
+
<a href="../#my-letter-to-you" tabindex="1" class="md-skip">
|
|
98
98
|
Skip to content
|
|
99
99
|
</a>
|
|
100
100
|
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
RBCli Documentation
|
|
121
121
|
</span>
|
|
122
122
|
<span class="md-header-nav__topic">
|
|
123
|
-
|
|
123
|
+
whoami
|
|
124
124
|
</span>
|
|
125
125
|
|
|
126
126
|
|
|
@@ -262,11 +262,11 @@
|
|
|
262
262
|
<div class="md-sidebar__inner">
|
|
263
263
|
<nav class="md-nav md-nav--primary" data-md-level="0">
|
|
264
264
|
<label class="md-nav__title md-nav__title--site" for="__drawer">
|
|
265
|
-
<
|
|
265
|
+
<a href=".." title="RBCli Documentation" class="md-nav__button md-logo">
|
|
266
266
|
|
|
267
267
|
<i class="md-icon">devices</i>
|
|
268
268
|
|
|
269
|
-
</
|
|
269
|
+
</a>
|
|
270
270
|
RBCli Documentation
|
|
271
271
|
</label>
|
|
272
272
|
|
|
@@ -462,6 +462,18 @@
|
|
|
462
462
|
|
|
463
463
|
|
|
464
464
|
|
|
465
|
+
<li class="md-nav__item">
|
|
466
|
+
<a href="../advanced/logging/" title="Logging" class="md-nav__link">
|
|
467
|
+
Logging
|
|
468
|
+
</a>
|
|
469
|
+
</li>
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
465
477
|
<li class="md-nav__item">
|
|
466
478
|
<a href="../advanced/automatic_updates/" title="Automatic Updates" class="md-nav__link">
|
|
467
479
|
Automatic Updates
|
|
@@ -505,6 +517,18 @@
|
|
|
505
517
|
</li>
|
|
506
518
|
|
|
507
519
|
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
<li class="md-nav__item">
|
|
526
|
+
<a href="../advanced/interactive_commands/" title="Interactive Commands" class="md-nav__link">
|
|
527
|
+
Interactive Commands
|
|
528
|
+
</a>
|
|
529
|
+
</li>
|
|
530
|
+
|
|
531
|
+
|
|
508
532
|
</ul>
|
|
509
533
|
</nav>
|
|
510
534
|
</li>
|
|
@@ -596,8 +620,8 @@
|
|
|
596
620
|
|
|
597
621
|
|
|
598
622
|
|
|
599
|
-
<a href="./" title="
|
|
600
|
-
|
|
623
|
+
<a href="./" title="whoami" class="md-nav__link md-nav__link--active">
|
|
624
|
+
whoami
|
|
601
625
|
</a>
|
|
602
626
|
|
|
603
627
|
</li>
|
|
@@ -709,9 +733,9 @@
|
|
|
709
733
|
|
|
710
734
|
</div>
|
|
711
735
|
|
|
712
|
-
<script src="../assets/javascripts/application.
|
|
736
|
+
<script src="../assets/javascripts/application.583bbe55.js"></script>
|
|
713
737
|
|
|
714
|
-
<script>app.initialize({version:"0.
|
|
738
|
+
<script>app.initialize({version:"1.0.3",url:{base:".."}})</script>
|
|
715
739
|
|
|
716
740
|
|
|
717
741
|
|
data/exe/rbcli
CHANGED
|
@@ -58,8 +58,8 @@ This is free software, and you are welcome to redistribute it
|
|
|
58
58
|
under certain conditions.
|
|
59
59
|
If you wish to release this library as part of commercial software,
|
|
60
60
|
please contact andrew@blacknex.us.
|
|
61
|
-
Type `rbcli license --full' to show the license text.
|
|
62
61
|
EOF
|
|
62
|
+
puts "Type `rbcli license --full' to show the license text." unless params[:full]
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
|
data/lib/rbcli/engine/command.rb
CHANGED
|
@@ -62,7 +62,7 @@ class Rbcli::Command
|
|
|
62
62
|
def self.remote_permitted?; @data[:remote_permitted]; end
|
|
63
63
|
def self.config_defaults filename; Rbcli::Config::add_defaults(filename); end
|
|
64
64
|
def self.config_default *params; Rbcli::Config::add_default *params; end
|
|
65
|
-
def self.parameter name, description, short: nil, type: :boolean, default: nil, required: false, permitted: nil
|
|
65
|
+
def self.parameter name, description, short: nil, type: :boolean, default: nil, required: false, permitted: nil, prompt: nil
|
|
66
66
|
default ||= false if (type == :boolean || type == :bool || type == :flag)
|
|
67
67
|
@data[:paramlist][name.to_sym] = {
|
|
68
68
|
description: description,
|
|
@@ -70,7 +70,8 @@ class Rbcli::Command
|
|
|
70
70
|
default: default,
|
|
71
71
|
required: required,
|
|
72
72
|
permitted: permitted,
|
|
73
|
-
short: short
|
|
73
|
+
short: short,
|
|
74
|
+
prompt: prompt
|
|
74
75
|
}
|
|
75
76
|
end
|
|
76
77
|
|
|
@@ -162,6 +163,31 @@ Command-specific Parameters:
|
|
|
162
163
|
end if params.is_a? Hash
|
|
163
164
|
end
|
|
164
165
|
optx[:args] = ARGV
|
|
166
|
+
params.each do |name, data|
|
|
167
|
+
given_symbol = (name.to_s + '_given').to_sym
|
|
168
|
+
if data[:prompt] and not (optx.key?(given_symbol) and optx[given_symbol])
|
|
169
|
+
if data[:type] == :bool or data[:type] == :boolean or data[:type] == :flag
|
|
170
|
+
answer = 'INVALID_STRING'
|
|
171
|
+
while answer.downcase != 'y' and answer.downcase != 'n' and answer.downcase != ''
|
|
172
|
+
print 'Invalid entry. '.red unless answer == 'INVALID_STRING'
|
|
173
|
+
print data[:prompt] + " (#{(data[:default]) ? 'Y/n' : 'y/N'}): "
|
|
174
|
+
answer = gets.chomp
|
|
175
|
+
if answer.downcase == 'y'
|
|
176
|
+
optx[name] = true
|
|
177
|
+
elsif answer.downcase == 'n'
|
|
178
|
+
optx[name] = false
|
|
179
|
+
elsif answer.downcase == ''
|
|
180
|
+
optx[name] = data[:default]
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
elsif data[:type] == :string
|
|
184
|
+
print data[:prompt] + " (default: \"#{data[:default]}\"): "
|
|
185
|
+
answer = gets.chomp
|
|
186
|
+
answer = data[:default] if answer.empty?
|
|
187
|
+
optx[name] = answer
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
165
191
|
optx
|
|
166
192
|
end
|
|
167
193
|
|