rbcli 0.1.10 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile.lock +12 -12
- data/LICENSE.txt +674 -21
- data/README.md +80 -443
- data/bin/console +19 -0
- data/bin/setup +20 -0
- data/docs/404.html +639 -0
- data/docs/advanced/automatic_updates/index.html +791 -0
- data/docs/advanced/command_types/index.html +946 -0
- data/docs/advanced/distributed_state_locking/index.html +777 -0
- data/docs/advanced/hooks/index.html +836 -0
- data/docs/advanced/state_storage/index.html +957 -0
- data/docs/advanced/user_config_files/index.html +818 -0
- data/docs/assets/fonts/font-awesome.css +4 -0
- data/docs/assets/fonts/material-icons.css +13 -0
- data/docs/assets/fonts/specimen/FontAwesome.ttf +0 -0
- data/docs/assets/fonts/specimen/FontAwesome.woff +0 -0
- data/docs/assets/fonts/specimen/FontAwesome.woff2 +0 -0
- data/docs/assets/fonts/specimen/MaterialIcons-Regular.ttf +0 -0
- data/docs/assets/fonts/specimen/MaterialIcons-Regular.woff +0 -0
- data/docs/assets/fonts/specimen/MaterialIcons-Regular.woff2 +0 -0
- data/docs/assets/images/favicon.png +0 -0
- data/docs/assets/images/icons/bitbucket.1b09e088.svg +20 -0
- data/docs/assets/images/icons/github.f0b8504a.svg +18 -0
- data/docs/assets/images/icons/gitlab.6dd19c00.svg +38 -0
- data/docs/assets/javascripts/application.a59e2a89.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.da.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.de.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.du.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.es.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.fi.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.fr.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.hu.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.it.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.jp.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.multi.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.no.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.pt.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.ro.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.ru.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.stemmer.support.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.sv.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.tr.js +1 -0
- data/docs/assets/javascripts/lunr/tinyseg.js +1 -0
- data/docs/assets/javascripts/modernizr.1aa3b519.js +1 -0
- data/docs/assets/stylesheets/application-palette.6079476c.css +2 -0
- data/docs/assets/stylesheets/application.ba0fd1a6.css +2 -0
- data/docs/development/code_of_conduct/index.html +883 -0
- data/docs/development/contributing/index.html +744 -0
- data/docs/development/license/index.html +715 -0
- data/docs/imported/changelog/index.html +853 -0
- data/docs/imported/quick_reference/index.html +1057 -0
- data/docs/index.html +732 -0
- data/docs/search/search_index.json +569 -0
- data/docs/sitemap.xml +93 -0
- data/docs/tutorial/10-getting_started/index.html +806 -0
- data/docs/tutorial/20-project_layout/index.html +972 -0
- data/docs/tutorial/30-your_first_command/index.html +906 -0
- data/docs/tutorial/40-options_parameters_and_arguments/index.html +1049 -0
- data/docs/tutorial/50-publishing/index.html +838 -0
- data/docs/whoami/index.html +709 -0
- data/docs-src/docs/advanced/automatic_updates.md +42 -0
- data/docs-src/docs/advanced/command_types.md +144 -0
- data/docs-src/docs/advanced/distributed_state_locking.md +33 -0
- data/docs-src/docs/advanced/hooks.md +65 -0
- data/docs-src/docs/advanced/logging.md +35 -0
- data/docs-src/docs/advanced/state_storage.md +117 -0
- data/docs-src/docs/advanced/user_config_files.md +47 -0
- data/docs-src/docs/development/code_of_conduct.md +74 -0
- data/docs-src/docs/development/contributing.md +49 -0
- data/docs-src/docs/development/license.md +10 -0
- data/docs-src/docs/imported/changelog.md +31 -0
- data/docs-src/docs/imported/quick_reference.md +150 -0
- data/docs-src/docs/index.md +38 -0
- data/docs-src/docs/tutorial/10-getting_started.md +41 -0
- data/docs-src/docs/tutorial/20-project_layout.md +115 -0
- data/docs-src/docs/tutorial/30-your_first_command.md +126 -0
- data/docs-src/docs/tutorial/40-options_parameters_and_arguments.md +251 -0
- data/docs-src/docs/tutorial/50-publishing.md +47 -0
- data/docs-src/docs/whoami.md +28 -0
- data/docs-src/makesite.sh +14 -0
- data/docs-src/mkdocs.yml +76 -0
- data/docs-src/runsite.sh +3 -0
- data/exe/rbcli +76 -5
- data/lib/rbcli/autoupdate/autoupdate.rb +24 -4
- data/lib/rbcli/autoupdate/gem_updater.rb +23 -2
- data/lib/rbcli/autoupdate/github_updater.rb +22 -1
- data/lib/rbcli/configuration/config.rb +22 -1
- data/lib/rbcli/configuration/configurate.rb +24 -2
- data/lib/rbcli/engine/command.rb +26 -6
- data/lib/rbcli/engine/load_project.rb +29 -3
- data/lib/rbcli/engine/parser.rb +25 -4
- data/lib/rbcli/logging/logging.rb +21 -0
- data/lib/rbcli/scriptwrapping/scriptwrapper.rb +30 -11
- data/lib/rbcli/stateful_systems/configuratestorage.rb +20 -0
- data/lib/rbcli/stateful_systems/state_storage.rb +20 -0
- data/lib/rbcli/stateful_systems/storagetypes/localstate.rb +20 -0
- data/lib/rbcli/stateful_systems/storagetypes/remote_state_connectors/dynamodb.rb +20 -0
- data/lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb +20 -0
- data/lib/rbcli/util/hash_deep_symbolize.rb +43 -22
- data/lib/rbcli/util/string_colorize.rb +20 -0
- data/lib/rbcli/version.rb +21 -1
- data/lib/rbcli-tool/generators.rb +20 -0
- data/lib/rbcli-tool/mdless_fix.rb +20 -0
- data/lib/rbcli-tool/project.rb +27 -2
- data/lib/rbcli-tool/util.rb +20 -0
- data/lib/rbcli-tool.rb +20 -0
- data/lib/rbcli.rb +20 -0
- data/lib-sh/lib-rbcli.sh +19 -0
- data/rbcli.gemspec +22 -3
- data/skeletons/project/CODE_OF_CONDUCT.md +1 -1
- data/skeletons/project/README.md +17 -2
- data/skeletons/project/application/commands/command.erb +10 -8
- data/skeletons/project/application/commands/script.erb +3 -1
- data/skeletons/project/application/commands/scripts/script.sh +2 -2
- data/skeletons/project/application/options.rb +12 -3
- data/skeletons/project/config/autoupdate.rb +5 -2
- data/skeletons/project/config/storage.rb +7 -6
- data/skeletons/project/config/userspace.rb +6 -1
- data/skeletons/project/exe/executable +1 -1
- data/skeletons/project/lib/.keep +0 -0
- data/skeletons/project/untitled.gemspec +4 -4
- data/skeletons/project/{default_user_configs → userconf}/user_defaults.yml +0 -0
- metadata +85 -9
- data/examples/defaults.yml +0 -4
- data/examples/myscript.sh +0 -23
- data/examples/mytool +0 -95
@@ -0,0 +1,906 @@
|
|
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>Your First Command - 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="#your-first-command" 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
|
+
Your First Command
|
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
|
+

|
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="../10-getting_started/" title="Tutorial" class="md-tabs__link md-tabs__link--active">
|
219
|
+
Tutorial
|
220
|
+
</a>
|
221
|
+
|
222
|
+
</li>
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
<li class="md-tabs__item">
|
230
|
+
|
231
|
+
<a href="../../advanced/command_types/" title="Advanced Features" class="md-tabs__link">
|
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
|
+
|
329
|
+
|
330
|
+
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
|
331
|
+
|
332
|
+
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-3" type="checkbox" id="nav-3" checked>
|
333
|
+
|
334
|
+
<label class="md-nav__link" for="nav-3">
|
335
|
+
Tutorial
|
336
|
+
</label>
|
337
|
+
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
|
338
|
+
<label class="md-nav__title" for="nav-3">
|
339
|
+
Tutorial
|
340
|
+
</label>
|
341
|
+
<ul class="md-nav__list" data-md-scrollfix>
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
<li class="md-nav__item">
|
350
|
+
<a href="../10-getting_started/" title="Getting Started" class="md-nav__link">
|
351
|
+
Getting Started
|
352
|
+
</a>
|
353
|
+
</li>
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
<li class="md-nav__item">
|
362
|
+
<a href="../20-project_layout/" title="The Project Layout" class="md-nav__link">
|
363
|
+
The Project Layout
|
364
|
+
</a>
|
365
|
+
</li>
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
<li class="md-nav__item md-nav__item--active">
|
376
|
+
|
377
|
+
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="__toc">
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
<label class="md-nav__link md-nav__link--active" for="__toc">
|
383
|
+
Your First Command
|
384
|
+
</label>
|
385
|
+
|
386
|
+
<a href="./" title="Your First Command" class="md-nav__link md-nav__link--active">
|
387
|
+
Your First Command
|
388
|
+
</a>
|
389
|
+
|
390
|
+
|
391
|
+
<nav class="md-nav md-nav--secondary">
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
<label class="md-nav__title" for="__toc">Table of contents</label>
|
398
|
+
<ul class="md-nav__list" data-md-scrollfix>
|
399
|
+
|
400
|
+
<li class="md-nav__item">
|
401
|
+
<a href="#creating-the-command" title="Creating the Command" class="md-nav__link">
|
402
|
+
Creating the Command
|
403
|
+
</a>
|
404
|
+
|
405
|
+
</li>
|
406
|
+
|
407
|
+
<li class="md-nav__item">
|
408
|
+
<a href="#the-command-declaration" title="The Command Declaration" class="md-nav__link">
|
409
|
+
The Command Declaration
|
410
|
+
</a>
|
411
|
+
|
412
|
+
</li>
|
413
|
+
|
414
|
+
<li class="md-nav__item">
|
415
|
+
<a href="#creating-the-list-command" title="Creating the "list" Command" class="md-nav__link">
|
416
|
+
Creating the "list" Command
|
417
|
+
</a>
|
418
|
+
|
419
|
+
</li>
|
420
|
+
|
421
|
+
<li class="md-nav__item">
|
422
|
+
<a href="#next-steps" title="Next Steps" class="md-nav__link">
|
423
|
+
Next Steps
|
424
|
+
</a>
|
425
|
+
|
426
|
+
</li>
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
</ul>
|
433
|
+
|
434
|
+
</nav>
|
435
|
+
|
436
|
+
</li>
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
|
444
|
+
<li class="md-nav__item">
|
445
|
+
<a href="../40-options_parameters_and_arguments/" title="Options, Parameters, and Arguments" class="md-nav__link">
|
446
|
+
Options, Parameters, and Arguments
|
447
|
+
</a>
|
448
|
+
</li>
|
449
|
+
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
|
456
|
+
<li class="md-nav__item">
|
457
|
+
<a href="../50-publishing/" title="Publishing and Distribution" class="md-nav__link">
|
458
|
+
Publishing and Distribution
|
459
|
+
</a>
|
460
|
+
</li>
|
461
|
+
|
462
|
+
|
463
|
+
</ul>
|
464
|
+
</nav>
|
465
|
+
</li>
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
<li class="md-nav__item md-nav__item--nested">
|
474
|
+
|
475
|
+
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-4" type="checkbox" id="nav-4">
|
476
|
+
|
477
|
+
<label class="md-nav__link" for="nav-4">
|
478
|
+
Advanced Features
|
479
|
+
</label>
|
480
|
+
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
|
481
|
+
<label class="md-nav__title" for="nav-4">
|
482
|
+
Advanced Features
|
483
|
+
</label>
|
484
|
+
<ul class="md-nav__list" data-md-scrollfix>
|
485
|
+
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
|
492
|
+
<li class="md-nav__item">
|
493
|
+
<a href="../../advanced/command_types/" title="Command Types" class="md-nav__link">
|
494
|
+
Command Types
|
495
|
+
</a>
|
496
|
+
</li>
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
<li class="md-nav__item">
|
505
|
+
<a href="../../advanced/user_config_files/" title="User Config Files" class="md-nav__link">
|
506
|
+
User Config Files
|
507
|
+
</a>
|
508
|
+
</li>
|
509
|
+
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
|
516
|
+
<li class="md-nav__item">
|
517
|
+
<a href="../../advanced/hooks/" title="Hooks" class="md-nav__link">
|
518
|
+
Hooks
|
519
|
+
</a>
|
520
|
+
</li>
|
521
|
+
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
|
528
|
+
<li class="md-nav__item">
|
529
|
+
<a href="../../advanced/automatic_updates/" title="Automatic Updates" class="md-nav__link">
|
530
|
+
Automatic Updates
|
531
|
+
</a>
|
532
|
+
</li>
|
533
|
+
|
534
|
+
|
535
|
+
|
536
|
+
|
537
|
+
|
538
|
+
|
539
|
+
|
540
|
+
<li class="md-nav__item">
|
541
|
+
<a href="../../advanced/state_storage/" title="State Storage" class="md-nav__link">
|
542
|
+
State Storage
|
543
|
+
</a>
|
544
|
+
</li>
|
545
|
+
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
|
550
|
+
|
551
|
+
|
552
|
+
<li class="md-nav__item">
|
553
|
+
<a href="../../advanced/distributed_state_locking/" title="Distributed State Locking" class="md-nav__link">
|
554
|
+
Distributed State Locking
|
555
|
+
</a>
|
556
|
+
</li>
|
557
|
+
|
558
|
+
|
559
|
+
</ul>
|
560
|
+
</nav>
|
561
|
+
</li>
|
562
|
+
|
563
|
+
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
<li class="md-nav__item md-nav__item--nested">
|
570
|
+
|
571
|
+
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-5" type="checkbox" id="nav-5">
|
572
|
+
|
573
|
+
<label class="md-nav__link" for="nav-5">
|
574
|
+
Development
|
575
|
+
</label>
|
576
|
+
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
|
577
|
+
<label class="md-nav__title" for="nav-5">
|
578
|
+
Development
|
579
|
+
</label>
|
580
|
+
<ul class="md-nav__list" data-md-scrollfix>
|
581
|
+
|
582
|
+
|
583
|
+
|
584
|
+
|
585
|
+
|
586
|
+
|
587
|
+
|
588
|
+
<li class="md-nav__item">
|
589
|
+
<a href="../../development/contributing/" title="Contribution Guide" class="md-nav__link">
|
590
|
+
Contribution Guide
|
591
|
+
</a>
|
592
|
+
</li>
|
593
|
+
|
594
|
+
|
595
|
+
|
596
|
+
|
597
|
+
|
598
|
+
|
599
|
+
|
600
|
+
<li class="md-nav__item">
|
601
|
+
<a href="../../development/license/" title="License Info" class="md-nav__link">
|
602
|
+
License Info
|
603
|
+
</a>
|
604
|
+
</li>
|
605
|
+
|
606
|
+
|
607
|
+
|
608
|
+
|
609
|
+
|
610
|
+
|
611
|
+
|
612
|
+
<li class="md-nav__item">
|
613
|
+
<a href="../../development/code_of_conduct/" title="Code of Conduct" class="md-nav__link">
|
614
|
+
Code of Conduct
|
615
|
+
</a>
|
616
|
+
</li>
|
617
|
+
|
618
|
+
|
619
|
+
|
620
|
+
|
621
|
+
|
622
|
+
|
623
|
+
|
624
|
+
<li class="md-nav__item">
|
625
|
+
<a href="../../imported/changelog/" title="Changelog" class="md-nav__link">
|
626
|
+
Changelog
|
627
|
+
</a>
|
628
|
+
</li>
|
629
|
+
|
630
|
+
|
631
|
+
</ul>
|
632
|
+
</nav>
|
633
|
+
</li>
|
634
|
+
|
635
|
+
|
636
|
+
|
637
|
+
|
638
|
+
|
639
|
+
|
640
|
+
|
641
|
+
<li class="md-nav__item">
|
642
|
+
<a href="../../whoami/" title="$ whoami" class="md-nav__link">
|
643
|
+
$ whoami
|
644
|
+
</a>
|
645
|
+
</li>
|
646
|
+
|
647
|
+
|
648
|
+
</ul>
|
649
|
+
</nav>
|
650
|
+
</div>
|
651
|
+
</div>
|
652
|
+
</div>
|
653
|
+
|
654
|
+
|
655
|
+
<div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
|
656
|
+
<div class="md-sidebar__scrollwrap">
|
657
|
+
<div class="md-sidebar__inner">
|
658
|
+
|
659
|
+
<nav class="md-nav md-nav--secondary">
|
660
|
+
|
661
|
+
|
662
|
+
|
663
|
+
|
664
|
+
|
665
|
+
<label class="md-nav__title" for="__toc">Table of contents</label>
|
666
|
+
<ul class="md-nav__list" data-md-scrollfix>
|
667
|
+
|
668
|
+
<li class="md-nav__item">
|
669
|
+
<a href="#creating-the-command" title="Creating the Command" class="md-nav__link">
|
670
|
+
Creating the Command
|
671
|
+
</a>
|
672
|
+
|
673
|
+
</li>
|
674
|
+
|
675
|
+
<li class="md-nav__item">
|
676
|
+
<a href="#the-command-declaration" title="The Command Declaration" class="md-nav__link">
|
677
|
+
The Command Declaration
|
678
|
+
</a>
|
679
|
+
|
680
|
+
</li>
|
681
|
+
|
682
|
+
<li class="md-nav__item">
|
683
|
+
<a href="#creating-the-list-command" title="Creating the "list" Command" class="md-nav__link">
|
684
|
+
Creating the "list" Command
|
685
|
+
</a>
|
686
|
+
|
687
|
+
</li>
|
688
|
+
|
689
|
+
<li class="md-nav__item">
|
690
|
+
<a href="#next-steps" title="Next Steps" class="md-nav__link">
|
691
|
+
Next Steps
|
692
|
+
</a>
|
693
|
+
|
694
|
+
</li>
|
695
|
+
|
696
|
+
|
697
|
+
|
698
|
+
|
699
|
+
|
700
|
+
</ul>
|
701
|
+
|
702
|
+
</nav>
|
703
|
+
</div>
|
704
|
+
</div>
|
705
|
+
</div>
|
706
|
+
|
707
|
+
|
708
|
+
<div class="md-content">
|
709
|
+
<article class="md-content__inner md-typeset">
|
710
|
+
|
711
|
+
|
712
|
+
|
713
|
+
<h1 id="your-first-command">Your First Command</h1>
|
714
|
+
<h2 id="creating-the-command">Creating the Command</h2>
|
715
|
+
<p>Creating the command is straightforward:</p>
|
716
|
+
<pre><code class="bash">rbcli command --name=list
|
717
|
+
#or
|
718
|
+
rbcli command -n list
|
719
|
+
</code></pre>
|
720
|
+
|
721
|
+
<p>And there you have it! Now you can try out your command by typing:</p>
|
722
|
+
<pre><code class="bash">./exe/mytool list
|
723
|
+
</code></pre>
|
724
|
+
|
725
|
+
<p>Congrats! You should now see a generic output listing the values of several variables. We'll get into what they mean in a bit, but first, let's make the tool's execution a bit easier.</p>
|
726
|
+
<p>Now that you know your way around a project, its time to create your first command! But before we do, let's make development just a little bit easier. Go to the base directory of the folder and type:</p>
|
727
|
+
<pre><code class="bash">alias mytool="$(pwd)/exe/mytool"
|
728
|
+
</code></pre>
|
729
|
+
|
730
|
+
<p>And now you'll be able to execute your application as if it was already installed as a gem, without worrying about the working path. You can see this in action by running your application again, but without the path:</p>
|
731
|
+
<pre><code class="bash">mytool list
|
732
|
+
</code></pre>
|
733
|
+
|
734
|
+
<p>So, now let's take a more in-dpeth look at what the command code looks like.</p>
|
735
|
+
<h2 id="the-command-declaration">The Command Declaration</h2>
|
736
|
+
<p>As mentioned in the previous section, you can find your commands listed under the <code>application/commands/</code> directory. Each command will appear as its own unique file with some base code to work from. Let's take a look at that code a little more in-depth:</p>
|
737
|
+
<pre><code class="ruby">class List < Rbcli::Command # Declare a new command by subclassing Rbcli::Command
|
738
|
+
description 'TODO: Description goes here' # (Required) Short description for the global help
|
739
|
+
usage <<-EOF
|
740
|
+
TODO: Usage text goes here
|
741
|
+
EOF # (Required) Long description for the command-specific help
|
742
|
+
parameter :force, 'Force testing', type: :boolean, default: false, required: false # (Optional, Multiple) Add a command-specific CLI parameter. Can be called multiple times
|
743
|
+
|
744
|
+
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.
|
745
|
+
# 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
|
746
|
+
|
747
|
+
action do |params, args, global_opts, config| # (Required) Block to execute if the command is called.
|
748
|
+
Rbcli::log.info { 'These logs can go to STDERR, STDOUT, or a file' } # Example log. Interface is identical to Ruby's logger
|
749
|
+
puts "\nArgs:\n#{args}" # Arguments that came after the command on the CLI (i.e.: `mytool test bar baz` will yield args=['bar', 'baz'])
|
750
|
+
puts "Params:\n#{params}" # Parameters, as described through the option statements above
|
751
|
+
puts "Global opts:\n#{global_opts}" # Global Parameters, as descirbed in the Configurate section
|
752
|
+
puts "Config:\n#{config}" # Config file values
|
753
|
+
puts "LocalState:\n#{Rbcli.local_state}" # Local persistent state storage (when available) -- if unsure use Rbcli.local_state.nil?
|
754
|
+
puts "RemoteState:\n#{Rbcli.remote_state}" # Remote persistent state storage (when available) -- if unsure use Rbcli.remote_state.nil?
|
755
|
+
puts "\nDone!!!"
|
756
|
+
end
|
757
|
+
end
|
758
|
+
</code></pre>
|
759
|
+
|
760
|
+
<p>Commands are declared to RBCli simply by subclassing them from <code>Rbcli::Command</code> as shown above. Then, you have a list of declarations that tell RBCli information about it. They are:</p>
|
761
|
+
<ul>
|
762
|
+
<li><code>description</code><ul>
|
763
|
+
<li>A short description of the command, which will appear in the top-level help (when the user runs <code>mytool -h</code>).</li>
|
764
|
+
</ul>
|
765
|
+
</li>
|
766
|
+
<li><code>usage</code><ul>
|
767
|
+
<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>
|
768
|
+
</ul>
|
769
|
+
</li>
|
770
|
+
<li><code>parameter</code><ul>
|
771
|
+
<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="../40-options_parameters_and_arguments/">Options, Parameters, and Arguments</a></li>
|
772
|
+
</ul>
|
773
|
+
</li>
|
774
|
+
<li><code>config_default</code><ul>
|
775
|
+
<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="../../advanced/user_config_files/">User Config Files</a></li>
|
776
|
+
</ul>
|
777
|
+
</li>
|
778
|
+
<li><code>action</code><ul>
|
779
|
+
<li>This loads the block of code that will run when the command is called. It brings in all of the CLI and user config data as variables. We will also get into these in the next section <a href="../40-options_parameters_and_arguments/">Options, Parameters, and Arguments</a></li>
|
780
|
+
</ul>
|
781
|
+
</li>
|
782
|
+
</ul>
|
783
|
+
<p>There is an additional declaration not shown here, <code>extern</code>. You can find more information on it in the section on <a href="../../advanced/command_types/">Advanced Command Types</a></p>
|
784
|
+
<h2 id="creating-the-list-command">Creating the "list" Command</h2>
|
785
|
+
<p>Now we're going to modify this command to list the contents of the current directory to the terminal. So let's change the code in that file to:</p>
|
786
|
+
<pre><code class="ruby">class List < Rbcli::Command
|
787
|
+
description %q{List files in current directory}
|
788
|
+
usage <<-EOF
|
789
|
+
Ever wanted to see your files?
|
790
|
+
Now you can!
|
791
|
+
EOF
|
792
|
+
|
793
|
+
action do |params, args, global_opts, config|
|
794
|
+
filelist = []
|
795
|
+
|
796
|
+
# We store a list of the files in an array, including dotfiles if specified
|
797
|
+
Dir.glob "./*" do |filename|
|
798
|
+
outname = filename.split('/')[1]
|
799
|
+
outname += '/' if File.directory? filename
|
800
|
+
filelist.append outname
|
801
|
+
end
|
802
|
+
|
803
|
+
# Apply color
|
804
|
+
filelist.map! do |filename|
|
805
|
+
if File.directory? filename
|
806
|
+
filename.light_blue
|
807
|
+
elsif File.executable? filename
|
808
|
+
filename.light_green
|
809
|
+
else
|
810
|
+
filename
|
811
|
+
end
|
812
|
+
end if global_opts[:color]
|
813
|
+
|
814
|
+
puts filelist
|
815
|
+
end
|
816
|
+
end
|
817
|
+
</code></pre>
|
818
|
+
|
819
|
+
<p>Go ahead and test it out! The output doesn't show much obviously, just a list of names and nothing else. Don't worry though, we'll fix that in the next secion.</p>
|
820
|
+
<h2 id="next-steps">Next Steps</h2>
|
821
|
+
<p>Next we're going to take a look at options, parameters, and arguments, and we'll clean up our list command by using them. If you'd like to learn more about the additional command types in RBCli before continuing, see the <a href="../../advanced/command_types/">Advanced Command Types</a> documentation.</p>
|
822
|
+
|
823
|
+
|
824
|
+
|
825
|
+
|
826
|
+
|
827
|
+
|
828
|
+
|
829
|
+
|
830
|
+
|
831
|
+
</article>
|
832
|
+
</div>
|
833
|
+
</div>
|
834
|
+
</main>
|
835
|
+
|
836
|
+
|
837
|
+
<footer class="md-footer">
|
838
|
+
|
839
|
+
<div class="md-footer-nav">
|
840
|
+
<nav class="md-footer-nav__inner md-grid">
|
841
|
+
|
842
|
+
<a href="../20-project_layout/" title="The Project Layout" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
|
843
|
+
<div class="md-flex__cell md-flex__cell--shrink">
|
844
|
+
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
|
845
|
+
</div>
|
846
|
+
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
|
847
|
+
<span class="md-flex__ellipsis">
|
848
|
+
<span class="md-footer-nav__direction">
|
849
|
+
Previous
|
850
|
+
</span>
|
851
|
+
The Project Layout
|
852
|
+
</span>
|
853
|
+
</div>
|
854
|
+
</a>
|
855
|
+
|
856
|
+
|
857
|
+
<a href="../40-options_parameters_and_arguments/" title="Options, Parameters, and Arguments" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next">
|
858
|
+
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
|
859
|
+
<span class="md-flex__ellipsis">
|
860
|
+
<span class="md-footer-nav__direction">
|
861
|
+
Next
|
862
|
+
</span>
|
863
|
+
Options, Parameters, and Arguments
|
864
|
+
</span>
|
865
|
+
</div>
|
866
|
+
<div class="md-flex__cell md-flex__cell--shrink">
|
867
|
+
<i class="md-icon md-icon--arrow-forward md-footer-nav__button"></i>
|
868
|
+
</div>
|
869
|
+
</a>
|
870
|
+
|
871
|
+
</nav>
|
872
|
+
</div>
|
873
|
+
|
874
|
+
<div class="md-footer-meta md-typeset">
|
875
|
+
<div class="md-footer-meta__inner md-grid">
|
876
|
+
<div class="md-footer-copyright">
|
877
|
+
|
878
|
+
<div class="md-footer-copyright__highlight">
|
879
|
+
Copyright © 2018 Andrew Khoury
|
880
|
+
</div>
|
881
|
+
|
882
|
+
powered by
|
883
|
+
<a href="https://www.mkdocs.org">MkDocs</a>
|
884
|
+
and
|
885
|
+
<a href="https://squidfunk.github.io/mkdocs-material/">
|
886
|
+
Material for MkDocs</a>
|
887
|
+
</div>
|
888
|
+
|
889
|
+
|
890
|
+
|
891
|
+
</div>
|
892
|
+
</div>
|
893
|
+
</footer>
|
894
|
+
|
895
|
+
</div>
|
896
|
+
|
897
|
+
<script src="../../assets/javascripts/application.a59e2a89.js"></script>
|
898
|
+
|
899
|
+
<script>app.initialize({version:"0.17.5",url:{base:"../.."}})</script>
|
900
|
+
|
901
|
+
|
902
|
+
|
903
|
+
|
904
|
+
|
905
|
+
</body>
|
906
|
+
</html>
|