rbcli 0.1.10 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -0
  3. data/CODE_OF_CONDUCT.md +1 -1
  4. data/Gemfile.lock +12 -12
  5. data/LICENSE.txt +674 -21
  6. data/README.md +80 -443
  7. data/bin/console +19 -0
  8. data/bin/setup +20 -0
  9. data/docs/404.html +639 -0
  10. data/docs/advanced/automatic_updates/index.html +791 -0
  11. data/docs/advanced/command_types/index.html +946 -0
  12. data/docs/advanced/distributed_state_locking/index.html +777 -0
  13. data/docs/advanced/hooks/index.html +836 -0
  14. data/docs/advanced/state_storage/index.html +957 -0
  15. data/docs/advanced/user_config_files/index.html +818 -0
  16. data/docs/assets/fonts/font-awesome.css +4 -0
  17. data/docs/assets/fonts/material-icons.css +13 -0
  18. data/docs/assets/fonts/specimen/FontAwesome.ttf +0 -0
  19. data/docs/assets/fonts/specimen/FontAwesome.woff +0 -0
  20. data/docs/assets/fonts/specimen/FontAwesome.woff2 +0 -0
  21. data/docs/assets/fonts/specimen/MaterialIcons-Regular.ttf +0 -0
  22. data/docs/assets/fonts/specimen/MaterialIcons-Regular.woff +0 -0
  23. data/docs/assets/fonts/specimen/MaterialIcons-Regular.woff2 +0 -0
  24. data/docs/assets/images/favicon.png +0 -0
  25. data/docs/assets/images/icons/bitbucket.1b09e088.svg +20 -0
  26. data/docs/assets/images/icons/github.f0b8504a.svg +18 -0
  27. data/docs/assets/images/icons/gitlab.6dd19c00.svg +38 -0
  28. data/docs/assets/javascripts/application.a59e2a89.js +1 -0
  29. data/docs/assets/javascripts/lunr/lunr.da.js +1 -0
  30. data/docs/assets/javascripts/lunr/lunr.de.js +1 -0
  31. data/docs/assets/javascripts/lunr/lunr.du.js +1 -0
  32. data/docs/assets/javascripts/lunr/lunr.es.js +1 -0
  33. data/docs/assets/javascripts/lunr/lunr.fi.js +1 -0
  34. data/docs/assets/javascripts/lunr/lunr.fr.js +1 -0
  35. data/docs/assets/javascripts/lunr/lunr.hu.js +1 -0
  36. data/docs/assets/javascripts/lunr/lunr.it.js +1 -0
  37. data/docs/assets/javascripts/lunr/lunr.jp.js +1 -0
  38. data/docs/assets/javascripts/lunr/lunr.multi.js +1 -0
  39. data/docs/assets/javascripts/lunr/lunr.no.js +1 -0
  40. data/docs/assets/javascripts/lunr/lunr.pt.js +1 -0
  41. data/docs/assets/javascripts/lunr/lunr.ro.js +1 -0
  42. data/docs/assets/javascripts/lunr/lunr.ru.js +1 -0
  43. data/docs/assets/javascripts/lunr/lunr.stemmer.support.js +1 -0
  44. data/docs/assets/javascripts/lunr/lunr.sv.js +1 -0
  45. data/docs/assets/javascripts/lunr/lunr.tr.js +1 -0
  46. data/docs/assets/javascripts/lunr/tinyseg.js +1 -0
  47. data/docs/assets/javascripts/modernizr.1aa3b519.js +1 -0
  48. data/docs/assets/stylesheets/application-palette.6079476c.css +2 -0
  49. data/docs/assets/stylesheets/application.ba0fd1a6.css +2 -0
  50. data/docs/development/code_of_conduct/index.html +883 -0
  51. data/docs/development/contributing/index.html +744 -0
  52. data/docs/development/license/index.html +715 -0
  53. data/docs/imported/changelog/index.html +853 -0
  54. data/docs/imported/quick_reference/index.html +1057 -0
  55. data/docs/index.html +732 -0
  56. data/docs/search/search_index.json +569 -0
  57. data/docs/sitemap.xml +93 -0
  58. data/docs/tutorial/10-getting_started/index.html +806 -0
  59. data/docs/tutorial/20-project_layout/index.html +972 -0
  60. data/docs/tutorial/30-your_first_command/index.html +906 -0
  61. data/docs/tutorial/40-options_parameters_and_arguments/index.html +1049 -0
  62. data/docs/tutorial/50-publishing/index.html +838 -0
  63. data/docs/whoami/index.html +709 -0
  64. data/docs-src/docs/advanced/automatic_updates.md +42 -0
  65. data/docs-src/docs/advanced/command_types.md +144 -0
  66. data/docs-src/docs/advanced/distributed_state_locking.md +33 -0
  67. data/docs-src/docs/advanced/hooks.md +65 -0
  68. data/docs-src/docs/advanced/logging.md +35 -0
  69. data/docs-src/docs/advanced/state_storage.md +117 -0
  70. data/docs-src/docs/advanced/user_config_files.md +47 -0
  71. data/docs-src/docs/development/code_of_conduct.md +74 -0
  72. data/docs-src/docs/development/contributing.md +49 -0
  73. data/docs-src/docs/development/license.md +10 -0
  74. data/docs-src/docs/imported/changelog.md +31 -0
  75. data/docs-src/docs/imported/quick_reference.md +150 -0
  76. data/docs-src/docs/index.md +38 -0
  77. data/docs-src/docs/tutorial/10-getting_started.md +41 -0
  78. data/docs-src/docs/tutorial/20-project_layout.md +115 -0
  79. data/docs-src/docs/tutorial/30-your_first_command.md +126 -0
  80. data/docs-src/docs/tutorial/40-options_parameters_and_arguments.md +251 -0
  81. data/docs-src/docs/tutorial/50-publishing.md +47 -0
  82. data/docs-src/docs/whoami.md +28 -0
  83. data/docs-src/makesite.sh +14 -0
  84. data/docs-src/mkdocs.yml +76 -0
  85. data/docs-src/runsite.sh +3 -0
  86. data/exe/rbcli +76 -5
  87. data/lib/rbcli/autoupdate/autoupdate.rb +24 -4
  88. data/lib/rbcli/autoupdate/gem_updater.rb +23 -2
  89. data/lib/rbcli/autoupdate/github_updater.rb +22 -1
  90. data/lib/rbcli/configuration/config.rb +22 -1
  91. data/lib/rbcli/configuration/configurate.rb +24 -2
  92. data/lib/rbcli/engine/command.rb +26 -6
  93. data/lib/rbcli/engine/load_project.rb +29 -3
  94. data/lib/rbcli/engine/parser.rb +25 -4
  95. data/lib/rbcli/logging/logging.rb +21 -0
  96. data/lib/rbcli/scriptwrapping/scriptwrapper.rb +30 -11
  97. data/lib/rbcli/stateful_systems/configuratestorage.rb +20 -0
  98. data/lib/rbcli/stateful_systems/state_storage.rb +20 -0
  99. data/lib/rbcli/stateful_systems/storagetypes/localstate.rb +20 -0
  100. data/lib/rbcli/stateful_systems/storagetypes/remote_state_connectors/dynamodb.rb +20 -0
  101. data/lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb +20 -0
  102. data/lib/rbcli/util/hash_deep_symbolize.rb +43 -22
  103. data/lib/rbcli/util/string_colorize.rb +20 -0
  104. data/lib/rbcli/version.rb +21 -1
  105. data/lib/rbcli-tool/generators.rb +20 -0
  106. data/lib/rbcli-tool/mdless_fix.rb +20 -0
  107. data/lib/rbcli-tool/project.rb +27 -2
  108. data/lib/rbcli-tool/util.rb +20 -0
  109. data/lib/rbcli-tool.rb +20 -0
  110. data/lib/rbcli.rb +20 -0
  111. data/lib-sh/lib-rbcli.sh +19 -0
  112. data/rbcli.gemspec +22 -3
  113. data/skeletons/project/CODE_OF_CONDUCT.md +1 -1
  114. data/skeletons/project/README.md +17 -2
  115. data/skeletons/project/application/commands/command.erb +10 -8
  116. data/skeletons/project/application/commands/script.erb +3 -1
  117. data/skeletons/project/application/commands/scripts/script.sh +2 -2
  118. data/skeletons/project/application/options.rb +12 -3
  119. data/skeletons/project/config/autoupdate.rb +5 -2
  120. data/skeletons/project/config/storage.rb +7 -6
  121. data/skeletons/project/config/userspace.rb +6 -1
  122. data/skeletons/project/exe/executable +1 -1
  123. data/skeletons/project/lib/.keep +0 -0
  124. data/skeletons/project/untitled.gemspec +4 -4
  125. data/skeletons/project/{default_user_configs → userconf}/user_defaults.yml +0 -0
  126. metadata +85 -9
  127. data/examples/defaults.yml +0 -4
  128. data/examples/myscript.sh +0 -23
  129. data/examples/mytool +0 -95
@@ -0,0 +1,946 @@
1
+
2
+
3
+
4
+
5
+ <!DOCTYPE html>
6
+ <html lang="en" class="no-js">
7
+ <head>
8
+
9
+ <meta charset="utf-8">
10
+ <meta name="viewport" content="width=device-width,initial-scale=1">
11
+ <meta http-equiv="x-ua-compatible" content="ie=edge">
12
+
13
+ <meta name="description" content="Description">
14
+
15
+
16
+
17
+ <meta name="author" content="Andrew Khoury">
18
+
19
+
20
+ <meta name="lang:clipboard.copy" content="Copy to clipboard">
21
+
22
+ <meta name="lang:clipboard.copied" content="Copied to clipboard">
23
+
24
+ <meta name="lang:search.language" content="en">
25
+
26
+ <meta name="lang:search.pipeline.stopwords" content="True">
27
+
28
+ <meta name="lang:search.pipeline.trimmer" content="True">
29
+
30
+ <meta name="lang:search.result.none" content="No matching documents">
31
+
32
+ <meta name="lang:search.result.one" content="1 matching document">
33
+
34
+ <meta name="lang:search.result.other" content="# matching documents">
35
+
36
+ <meta name="lang:search.tokenizer" content="[\s\-]+">
37
+
38
+ <link rel="shortcut icon" href="../../assets/images/favicon.png">
39
+ <meta name="generator" content="mkdocs-0.17.5, mkdocs-material-2.9.2">
40
+
41
+
42
+
43
+ <title>Command Types - RBCli Documentation</title>
44
+
45
+
46
+
47
+ <link rel="stylesheet" href="../../assets/stylesheets/application.ba0fd1a6.css">
48
+
49
+
50
+
51
+
52
+ <script src="../../assets/javascripts/modernizr.1aa3b519.js"></script>
53
+
54
+
55
+ <link href="https://fonts.gstatic.com" rel="preconnect" crossorigin>
56
+
57
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono">
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
+
60
+
61
+ <link rel="stylesheet" href="../../assets/fonts/material-icons.css">
62
+
63
+
64
+ </head>
65
+
66
+ <body dir="ltr">
67
+
68
+ <svg class="md-svg">
69
+ <defs>
70
+
71
+
72
+ <svg xmlns="http://www.w3.org/2000/svg" width="416" height="448"
73
+ viewBox="0 0 416 448" id="__github">
74
+ <path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19-18.125
75
+ 8.5-18.125-8.5-10.75-19-3.125-20.5 3.125-20.5 10.75-19 18.125-8.5
76
+ 18.125 8.5 10.75 19 3.125 20.5zM320 304q0 10-3.125 20.5t-10.75
77
+ 19-18.125 8.5-18.125-8.5-10.75-19-3.125-20.5 3.125-20.5 10.75-19
78
+ 18.125-8.5 18.125 8.5 10.75 19 3.125 20.5zM360
79
+ 304q0-30-17.25-51t-46.75-21q-10.25 0-48.75 5.25-17.75 2.75-39.25
80
+ 2.75t-39.25-2.75q-38-5.25-48.75-5.25-29.5 0-46.75 21t-17.25 51q0 22 8
81
+ 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0
82
+ 37.25-1.75t35-7.375 30.5-15 20.25-25.75 8-38.375zM416 260q0 51.75-15.25
83
+ 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5-41.75
84
+ 1.125q-19.5 0-35.5-0.75t-36.875-3.125-38.125-7.5-34.25-12.875-30.25-20.25-21.5-28.75q-15.5-30.75-15.5-82.75
85
+ 0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25
86
+ 30.875q36.75-8.75 77.25-8.75 37 0 70 8 26.25-20.5
87
+ 46.75-30.25t47.25-9.75q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34
88
+ 99.5z" />
89
+ </svg>
90
+
91
+ </defs>
92
+ </svg>
93
+ <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
94
+ <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
95
+ <label class="md-overlay" data-md-component="overlay" for="__drawer"></label>
96
+
97
+ <a href="#advanced-command-types" tabindex="1" class="md-skip">
98
+ Skip to content
99
+ </a>
100
+
101
+
102
+ <header class="md-header" data-md-component="header">
103
+ <nav class="md-header-nav md-grid">
104
+ <div class="md-flex">
105
+ <div class="md-flex__cell md-flex__cell--shrink">
106
+ <a href="../.." title="RBCli Documentation" class="md-header-nav__button md-logo">
107
+
108
+ <i class="md-icon">devices</i>
109
+
110
+ </a>
111
+ </div>
112
+ <div class="md-flex__cell md-flex__cell--shrink">
113
+ <label class="md-icon md-icon--menu md-header-nav__button" for="__drawer"></label>
114
+ </div>
115
+ <div class="md-flex__cell md-flex__cell--stretch">
116
+ <div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
117
+
118
+
119
+ <span class="md-header-nav__topic">
120
+ RBCli Documentation
121
+ </span>
122
+ <span class="md-header-nav__topic">
123
+ Command Types
124
+ </span>
125
+
126
+
127
+ </div>
128
+ </div>
129
+ <div class="md-flex__cell md-flex__cell--shrink">
130
+
131
+
132
+ <label class="md-icon md-icon--search md-header-nav__button" for="__search"></label>
133
+
134
+ <div class="md-search" data-md-component="search" role="dialog">
135
+ <label class="md-search__overlay" for="__search"></label>
136
+ <div class="md-search__inner" role="search">
137
+ <form class="md-search__form" name="search">
138
+ <input type="text" class="md-search__input" name="query" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query" data-md-state="active">
139
+ <label class="md-icon md-search__icon" for="__search"></label>
140
+ <button type="reset" class="md-icon md-search__icon" data-md-component="reset" tabindex="-1">
141
+ &#xE5CD;
142
+ </button>
143
+ </form>
144
+ <div class="md-search__output">
145
+ <div class="md-search__scrollwrap" data-md-scrollfix>
146
+ <div class="md-search-result" data-md-component="result">
147
+ <div class="md-search-result__meta">
148
+ Type to start searching
149
+ </div>
150
+ <ol class="md-search-result__list"></ol>
151
+ </div>
152
+ </div>
153
+ </div>
154
+ </div>
155
+ </div>
156
+
157
+
158
+ </div>
159
+
160
+ <div class="md-flex__cell md-flex__cell--shrink">
161
+ <div class="md-header-nav__source">
162
+
163
+
164
+
165
+
166
+
167
+
168
+ <a href="https://github.com/akhoury6/rbcli/" title="Go to repository" class="md-source" data-md-source="github">
169
+
170
+ <div class="md-source__icon">
171
+ <svg viewBox="0 0 24 24" width="24" height="24">
172
+ <use xlink:href="#__github" width="24" height="24"></use>
173
+ </svg>
174
+ </div>
175
+
176
+ <div class="md-source__repository">
177
+ GitHub
178
+ </div>
179
+ </a>
180
+
181
+ </div>
182
+ </div>
183
+
184
+ </div>
185
+ </nav>
186
+ </header>
187
+
188
+ <div class="md-container">
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+ <nav class="md-tabs md-tabs--active" data-md-component="tabs">
198
+ <div class="md-tabs__inner md-grid">
199
+ <ul class="md-tabs__list">
200
+
201
+
202
+ <li class="md-tabs__item">
203
+
204
+ <a href="../.." title="Home" class="md-tabs__link">
205
+ Home
206
+ </a>
207
+
208
+ </li>
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+ <li class="md-tabs__item">
217
+
218
+ <a href="../../tutorial/10-getting_started/" title="Tutorial" class="md-tabs__link">
219
+ Tutorial
220
+ </a>
221
+
222
+ </li>
223
+
224
+
225
+
226
+
227
+
228
+
229
+ <li class="md-tabs__item">
230
+
231
+ <a href="./" title="Advanced Features" class="md-tabs__link md-tabs__link--active">
232
+ Advanced Features
233
+ </a>
234
+
235
+ </li>
236
+
237
+
238
+
239
+
240
+
241
+
242
+ <li class="md-tabs__item">
243
+
244
+ <a href="../../development/contributing/" title="Development" class="md-tabs__link">
245
+ Development
246
+ </a>
247
+
248
+ </li>
249
+
250
+
251
+
252
+
253
+
254
+ </ul>
255
+ </div>
256
+ </nav>
257
+
258
+ <main class="md-main">
259
+ <div class="md-main__inner md-grid" data-md-component="container">
260
+
261
+
262
+ <div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
263
+ <div class="md-sidebar__scrollwrap">
264
+ <div class="md-sidebar__inner">
265
+ <nav class="md-nav md-nav--primary" data-md-level="0">
266
+ <label class="md-nav__title md-nav__title--site" for="__drawer">
267
+ <span class="md-nav__button md-logo">
268
+
269
+ <i class="md-icon">devices</i>
270
+
271
+ </span>
272
+ RBCli Documentation
273
+ </label>
274
+
275
+ <div class="md-nav__source">
276
+
277
+
278
+
279
+
280
+
281
+
282
+ <a href="https://github.com/akhoury6/rbcli/" title="Go to repository" class="md-source" data-md-source="github">
283
+
284
+ <div class="md-source__icon">
285
+ <svg viewBox="0 0 24 24" width="24" height="24">
286
+ <use xlink:href="#__github" width="24" height="24"></use>
287
+ </svg>
288
+ </div>
289
+
290
+ <div class="md-source__repository">
291
+ GitHub
292
+ </div>
293
+ </a>
294
+
295
+ </div>
296
+
297
+ <ul class="md-nav__list" data-md-scrollfix>
298
+
299
+
300
+
301
+
302
+
303
+
304
+ <li class="md-nav__item">
305
+ <a href="../.." title="Home" class="md-nav__link">
306
+ Home
307
+ </a>
308
+ </li>
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+ <li class="md-nav__item">
317
+ <a href="../../imported/quick_reference/" title="Quick Reference" class="md-nav__link">
318
+ Quick Reference
319
+ </a>
320
+ </li>
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+ <li class="md-nav__item md-nav__item--nested">
329
+
330
+ <input class="md-toggle md-nav__toggle" data-md-toggle="nav-3" type="checkbox" id="nav-3">
331
+
332
+ <label class="md-nav__link" for="nav-3">
333
+ Tutorial
334
+ </label>
335
+ <nav class="md-nav" data-md-component="collapsible" data-md-level="1">
336
+ <label class="md-nav__title" for="nav-3">
337
+ Tutorial
338
+ </label>
339
+ <ul class="md-nav__list" data-md-scrollfix>
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+ <li class="md-nav__item">
348
+ <a href="../../tutorial/10-getting_started/" title="Getting Started" class="md-nav__link">
349
+ Getting Started
350
+ </a>
351
+ </li>
352
+
353
+
354
+
355
+
356
+
357
+
358
+
359
+ <li class="md-nav__item">
360
+ <a href="../../tutorial/20-project_layout/" title="The Project Layout" class="md-nav__link">
361
+ The Project Layout
362
+ </a>
363
+ </li>
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+ <li class="md-nav__item">
372
+ <a href="../../tutorial/30-your_first_command/" title="Your First Command" class="md-nav__link">
373
+ Your First Command
374
+ </a>
375
+ </li>
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+ <li class="md-nav__item">
384
+ <a href="../../tutorial/40-options_parameters_and_arguments/" title="Options, Parameters, and Arguments" class="md-nav__link">
385
+ Options, Parameters, and Arguments
386
+ </a>
387
+ </li>
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+ <li class="md-nav__item">
396
+ <a href="../../tutorial/50-publishing/" title="Publishing and Distribution" class="md-nav__link">
397
+ Publishing and Distribution
398
+ </a>
399
+ </li>
400
+
401
+
402
+ </ul>
403
+ </nav>
404
+ </li>
405
+
406
+
407
+
408
+
409
+
410
+
411
+
412
+
413
+
414
+ <li class="md-nav__item md-nav__item--active md-nav__item--nested">
415
+
416
+ <input class="md-toggle md-nav__toggle" data-md-toggle="nav-4" type="checkbox" id="nav-4" checked>
417
+
418
+ <label class="md-nav__link" for="nav-4">
419
+ Advanced Features
420
+ </label>
421
+ <nav class="md-nav" data-md-component="collapsible" data-md-level="1">
422
+ <label class="md-nav__title" for="nav-4">
423
+ Advanced Features
424
+ </label>
425
+ <ul class="md-nav__list" data-md-scrollfix>
426
+
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+ <li class="md-nav__item md-nav__item--active">
436
+
437
+ <input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="__toc">
438
+
439
+
440
+
441
+
442
+ <label class="md-nav__link md-nav__link--active" for="__toc">
443
+ Command Types
444
+ </label>
445
+
446
+ <a href="./" title="Command Types" class="md-nav__link md-nav__link--active">
447
+ Command Types
448
+ </a>
449
+
450
+
451
+ <nav class="md-nav md-nav--secondary">
452
+
453
+
454
+
455
+
456
+
457
+ <label class="md-nav__title" for="__toc">Table of contents</label>
458
+ <ul class="md-nav__list" data-md-scrollfix>
459
+
460
+ <li class="md-nav__item">
461
+ <a href="#general-command-structure" title="General Command Structure" class="md-nav__link">
462
+ General Command Structure
463
+ </a>
464
+
465
+ </li>
466
+
467
+ <li class="md-nav__item">
468
+ <a href="#standard-commands" title="Standard Commands" class="md-nav__link">
469
+ Standard Commands
470
+ </a>
471
+
472
+ </li>
473
+
474
+ <li class="md-nav__item">
475
+ <a href="#scripted-commands" title="Scripted Commands" class="md-nav__link">
476
+ Scripted Commands
477
+ </a>
478
+
479
+ </li>
480
+
481
+ <li class="md-nav__item">
482
+ <a href="#external-commands" title="External Commands" class="md-nav__link">
483
+ External Commands
484
+ </a>
485
+
486
+ <nav class="md-nav">
487
+ <ul class="md-nav__list">
488
+
489
+ <li class="md-nav__item">
490
+ <a href="#direct-path-mode" title="Direct Path Mode" class="md-nav__link">
491
+ Direct Path Mode
492
+ </a>
493
+
494
+ </li>
495
+
496
+ <li class="md-nav__item">
497
+ <a href="#variable-path-mode" title="Variable Path Mode" class="md-nav__link">
498
+ Variable Path Mode
499
+ </a>
500
+
501
+ </li>
502
+
503
+ </ul>
504
+ </nav>
505
+
506
+ </li>
507
+
508
+
509
+
510
+
511
+
512
+ </ul>
513
+
514
+ </nav>
515
+
516
+ </li>
517
+
518
+
519
+
520
+
521
+
522
+
523
+
524
+ <li class="md-nav__item">
525
+ <a href="../user_config_files/" title="User Config Files" class="md-nav__link">
526
+ User Config Files
527
+ </a>
528
+ </li>
529
+
530
+
531
+
532
+
533
+
534
+
535
+
536
+ <li class="md-nav__item">
537
+ <a href="../hooks/" title="Hooks" class="md-nav__link">
538
+ Hooks
539
+ </a>
540
+ </li>
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+ <li class="md-nav__item">
549
+ <a href="../automatic_updates/" title="Automatic Updates" class="md-nav__link">
550
+ Automatic Updates
551
+ </a>
552
+ </li>
553
+
554
+
555
+
556
+
557
+
558
+
559
+
560
+ <li class="md-nav__item">
561
+ <a href="../state_storage/" title="State Storage" class="md-nav__link">
562
+ State Storage
563
+ </a>
564
+ </li>
565
+
566
+
567
+
568
+
569
+
570
+
571
+
572
+ <li class="md-nav__item">
573
+ <a href="../distributed_state_locking/" title="Distributed State Locking" class="md-nav__link">
574
+ Distributed State Locking
575
+ </a>
576
+ </li>
577
+
578
+
579
+ </ul>
580
+ </nav>
581
+ </li>
582
+
583
+
584
+
585
+
586
+
587
+
588
+
589
+ <li class="md-nav__item md-nav__item--nested">
590
+
591
+ <input class="md-toggle md-nav__toggle" data-md-toggle="nav-5" type="checkbox" id="nav-5">
592
+
593
+ <label class="md-nav__link" for="nav-5">
594
+ Development
595
+ </label>
596
+ <nav class="md-nav" data-md-component="collapsible" data-md-level="1">
597
+ <label class="md-nav__title" for="nav-5">
598
+ Development
599
+ </label>
600
+ <ul class="md-nav__list" data-md-scrollfix>
601
+
602
+
603
+
604
+
605
+
606
+
607
+
608
+ <li class="md-nav__item">
609
+ <a href="../../development/contributing/" title="Contribution Guide" class="md-nav__link">
610
+ Contribution Guide
611
+ </a>
612
+ </li>
613
+
614
+
615
+
616
+
617
+
618
+
619
+
620
+ <li class="md-nav__item">
621
+ <a href="../../development/license/" title="License Info" class="md-nav__link">
622
+ License Info
623
+ </a>
624
+ </li>
625
+
626
+
627
+
628
+
629
+
630
+
631
+
632
+ <li class="md-nav__item">
633
+ <a href="../../development/code_of_conduct/" title="Code of Conduct" class="md-nav__link">
634
+ Code of Conduct
635
+ </a>
636
+ </li>
637
+
638
+
639
+
640
+
641
+
642
+
643
+
644
+ <li class="md-nav__item">
645
+ <a href="../../imported/changelog/" title="Changelog" class="md-nav__link">
646
+ Changelog
647
+ </a>
648
+ </li>
649
+
650
+
651
+ </ul>
652
+ </nav>
653
+ </li>
654
+
655
+
656
+
657
+
658
+
659
+
660
+
661
+ <li class="md-nav__item">
662
+ <a href="../../whoami/" title="$ whoami" class="md-nav__link">
663
+ $ whoami
664
+ </a>
665
+ </li>
666
+
667
+
668
+ </ul>
669
+ </nav>
670
+ </div>
671
+ </div>
672
+ </div>
673
+
674
+
675
+ <div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
676
+ <div class="md-sidebar__scrollwrap">
677
+ <div class="md-sidebar__inner">
678
+
679
+ <nav class="md-nav md-nav--secondary">
680
+
681
+
682
+
683
+
684
+
685
+ <label class="md-nav__title" for="__toc">Table of contents</label>
686
+ <ul class="md-nav__list" data-md-scrollfix>
687
+
688
+ <li class="md-nav__item">
689
+ <a href="#general-command-structure" title="General Command Structure" class="md-nav__link">
690
+ General Command Structure
691
+ </a>
692
+
693
+ </li>
694
+
695
+ <li class="md-nav__item">
696
+ <a href="#standard-commands" title="Standard Commands" class="md-nav__link">
697
+ Standard Commands
698
+ </a>
699
+
700
+ </li>
701
+
702
+ <li class="md-nav__item">
703
+ <a href="#scripted-commands" title="Scripted Commands" class="md-nav__link">
704
+ Scripted Commands
705
+ </a>
706
+
707
+ </li>
708
+
709
+ <li class="md-nav__item">
710
+ <a href="#external-commands" title="External Commands" class="md-nav__link">
711
+ External Commands
712
+ </a>
713
+
714
+ <nav class="md-nav">
715
+ <ul class="md-nav__list">
716
+
717
+ <li class="md-nav__item">
718
+ <a href="#direct-path-mode" title="Direct Path Mode" class="md-nav__link">
719
+ Direct Path Mode
720
+ </a>
721
+
722
+ </li>
723
+
724
+ <li class="md-nav__item">
725
+ <a href="#variable-path-mode" title="Variable Path Mode" class="md-nav__link">
726
+ Variable Path Mode
727
+ </a>
728
+
729
+ </li>
730
+
731
+ </ul>
732
+ </nav>
733
+
734
+ </li>
735
+
736
+
737
+
738
+
739
+
740
+ </ul>
741
+
742
+ </nav>
743
+ </div>
744
+ </div>
745
+ </div>
746
+
747
+
748
+ <div class="md-content">
749
+ <article class="md-content__inner md-typeset">
750
+
751
+
752
+
753
+ <h1 id="advanced-command-types">Advanced Command Types</h1>
754
+ <p>RBCli has three different command types:</p>
755
+ <ul>
756
+ <li><strong>Standard Commands</strong> (Ruby-based)</li>
757
+ <li><strong>Scripted Commands</strong> (Ruby+Bash based)</li>
758
+ <li><strong>External Commands</strong> (Wrapping a 3rd party application)</li>
759
+ </ul>
760
+ <p>This document is provided to be a reference. If you would like an in-depth tutorial, please see <a href="../../tutorial/30-your_first_command/">Your First Command</a>.</p>
761
+ <h2 id="general-command-structure">General Command Structure</h2>
762
+ <p>Commands in RBCli are created by subclassing <code>Rbcli::Command</code>. All commands share a certain common structure:</p>
763
+ <pre><code class="ruby">class List &lt; Rbcli::Command # Declare a new command by subclassing Rbcli::Command
764
+ description 'TODO: Description goes here' # (Required) Short description for the global help
765
+ usage &lt;&lt;-EOF
766
+ TODO: Usage text goes here
767
+ EOF # (Required) Long description for the command-specific help
768
+ parameter :force, 'Force testing', type: :boolean, default: false, required: false # (Optional, Multiple) Add a command-specific CLI parameter. Can be called multiple times
769
+
770
+ config_default :myopt2, description: 'My Option #2', default: 'Default Value Here' # (Optional, Multiple) Specify an individual configuration parameter and set a default value. These will also be included in generated user config.
771
+ # 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
772
+ end
773
+ </code></pre>
774
+
775
+ <ul>
776
+ <li><code>description</code><ul>
777
+ <li>A short description of the command, which will appear in the top-level help (when the user runs <code>mytool -h</code>).</li>
778
+ </ul>
779
+ </li>
780
+ <li><code>usage</code><ul>
781
+ <li>A description of how the command is meant to be used. This description can be as long as you want, and can be as in-depth as you'd like. It will show up as a long, multi-line description when the user runs the command-sepcific help (<code>mytool list -h</code>).</li>
782
+ </ul>
783
+ </li>
784
+ <li><code>parameter</code><ul>
785
+ <li>Command-line tags that the user can enter that are specific to only this command. We will get into these in the next section on <a href="../../tutorial/40-options_parameters_and_arguments/">Options, Parameters, and Arguments</a></li>
786
+ </ul>
787
+ </li>
788
+ <li><code>config_default</code><ul>
789
+ <li>This sets a single item in the config file that will be made available to the user. More information can be found in the documentation on <a href="../user_config_files/">User Config Files</a></li>
790
+ </ul>
791
+ </li>
792
+ </ul>
793
+ <h2 id="standard-commands">Standard Commands</h2>
794
+ <p>Standard commands are written as ruby code. To create a standard command called <code>list</code>, run:</p>
795
+ <pre><code class="bash">rbcli command --name=list
796
+ #or
797
+ rbcli command -n list
798
+ </code></pre>
799
+
800
+ <p>A standard command can be identified by the presence of an <code>action</code> block in the definition:</p>
801
+ <pre><code class="ruby">class List &lt; Rbcli::Command
802
+ action do |params, args, global_opts, config|
803
+ # Code goes here
804
+ end
805
+ end
806
+ </code></pre>
807
+
808
+ <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="../../tutorial/40-options_parameters_and_arguments/">Options, Parameters, and Arguments</a>.</p>
809
+ <h2 id="scripted-commands">Scripted Commands</h2>
810
+ <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>
811
+ <pre><code class="bash">rbcli script -n list
812
+ </code></pre>
813
+
814
+ <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>
815
+ <p>You can tell a command is a script by the line:</p>
816
+ <pre><code class="ruby">class List &lt; Rbcli::Command
817
+ extern path: :default # (Required): Do not edit this line. Do delete it if you wish to manually specify a script path and set environment variables.
818
+ end
819
+ </code></pre>
820
+
821
+ <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>
822
+ <pre><code class="bash">source $(echo $(cd &quot;$(dirname $(gem which rbcli))/../lib-sh&quot; &amp;&amp; pwd)/lib-rbcli.sh)
823
+ </code></pre>
824
+
825
+ <p>This will find the library which is stored on the system as part of the RBCli gem.</p>
826
+ <p>You can then retrieve the values present in your variables like such:</p>
827
+ <pre><code class="bash">rbcli params
828
+ rbcli args
829
+ rbcli global_opts
830
+ rbcli config
831
+ rbcli myvars
832
+
833
+ echo &quot;Usage Examples:&quot;
834
+ echo &quot;Log Level: $(rbcli config .logger.log_level)&quot;
835
+ echo &quot;Log Target: $(rbcli config .logger.log_target)&quot;
836
+ echo &quot;First Argument (if passed): $(rbcli args .[0])&quot;
837
+ </code></pre>
838
+
839
+ <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>
840
+ <h2 id="external-commands">External Commands</h2>
841
+ <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>
842
+ <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>
843
+ <h3 id="direct-path-mode">Direct Path Mode</h3>
844
+ <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>
845
+ <p><code>ruby
846
+ class List &lt; Rbcli::Command
847
+ extern path: 'path/to/application', envvars: {MYVAR: 'some_value'} # (Required) Runs a given application, with optional environment variables, when the user runs the command.
848
+ end</code></p>
849
+ <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>
850
+ <h3 id="variable-path-mode">Variable Path Mode</h3>
851
+ <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>
852
+ <pre><code class="ruby">class Test &lt; Rbcli::Command
853
+ extern envvars: {MY_OTHER_VAR: 'another_value'} do |params, args, global_opts, config| # 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.
854
+ cmd = '/path/to/application'
855
+ cmd += ' --test-script foo --ignore-errors' if params[:force]
856
+ cmd
857
+ end
858
+ end
859
+ </code></pre>
860
+
861
+ <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>
862
+
863
+
864
+
865
+
866
+
867
+
868
+
869
+
870
+
871
+ </article>
872
+ </div>
873
+ </div>
874
+ </main>
875
+
876
+
877
+ <footer class="md-footer">
878
+
879
+ <div class="md-footer-nav">
880
+ <nav class="md-footer-nav__inner md-grid">
881
+
882
+ <a href="../../tutorial/50-publishing/" title="Publishing and Distribution" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
883
+ <div class="md-flex__cell md-flex__cell--shrink">
884
+ <i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
885
+ </div>
886
+ <div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
887
+ <span class="md-flex__ellipsis">
888
+ <span class="md-footer-nav__direction">
889
+ Previous
890
+ </span>
891
+ Publishing and Distribution
892
+ </span>
893
+ </div>
894
+ </a>
895
+
896
+
897
+ <a href="../user_config_files/" title="User Config Files" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next">
898
+ <div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
899
+ <span class="md-flex__ellipsis">
900
+ <span class="md-footer-nav__direction">
901
+ Next
902
+ </span>
903
+ User Config Files
904
+ </span>
905
+ </div>
906
+ <div class="md-flex__cell md-flex__cell--shrink">
907
+ <i class="md-icon md-icon--arrow-forward md-footer-nav__button"></i>
908
+ </div>
909
+ </a>
910
+
911
+ </nav>
912
+ </div>
913
+
914
+ <div class="md-footer-meta md-typeset">
915
+ <div class="md-footer-meta__inner md-grid">
916
+ <div class="md-footer-copyright">
917
+
918
+ <div class="md-footer-copyright__highlight">
919
+ Copyright © 2018 Andrew Khoury
920
+ </div>
921
+
922
+ powered by
923
+ <a href="https://www.mkdocs.org">MkDocs</a>
924
+ and
925
+ <a href="https://squidfunk.github.io/mkdocs-material/">
926
+ Material for MkDocs</a>
927
+ </div>
928
+
929
+
930
+
931
+ </div>
932
+ </div>
933
+ </footer>
934
+
935
+ </div>
936
+
937
+ <script src="../../assets/javascripts/application.a59e2a89.js"></script>
938
+
939
+ <script>app.initialize({version:"0.17.5",url:{base:"../.."}})</script>
940
+
941
+
942
+
943
+
944
+
945
+ </body>
946
+ </html>