You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
environment variables required (or desired) by your script.
185
-
186
-
### Command options
187
-
188
-
Unless otherwise specified, these definitions can be used for both the root
189
-
command and subcommands (under the `commands` definition).
190
-
191
-
Option | Description
192
-
-----------|-------------
193
-
`name` | The name of the script or subcommand.
194
-
`short` | An additional, optional pattern - usually used to denote a one letter variation of the command name. You can add `*` as a suffix, to denote a "starts with" pattern - for example `short: m*`. *Applicable only in subcommands*.
195
-
`help` | The header text to display when using `--help`. This option can have multiple lines. In this case, the first line will be used as summary wherever appropriate.
196
-
`version` | The string to display when using `--version`. *Applicable only in the main command*.
197
-
`default` | Setting this to `true` on any command, will cause any unrecognized command line to be passed to this command. *Applicable only in subcommands*.
198
-
`extensible` | Specify that this command can be [externally extended](#extensible-scripts). *Applicable only in the main command*.
199
-
`examples` | Specify an array of examples to show when using `--help`. Each example can have multiple lines.
200
-
`environment_variables` | Specify an array of [environment variables](#environment-variable-options) needed by your script.
201
-
`commands` | Specify the array of [commands](#command-options). Each command will have its own args and flags. Note: if `commands` is provided, you cannot specify flags or args at the same level.
202
-
`args` | Specify the array of [positional arguments](#argument-options) this script needs.
203
-
`flags` | Specify the array of option [flags](#flag-options) this script needs.
204
-
`completions` | Specify an array of additional completion suggestions when used in conjunction with `bashly add comp`. See [Bash Completions](#bash-completions).
205
-
`catch_all` | Specify that this command should allow for additional arbitrary arguments or flags. It can be set in one of three ways:<br>- Set to `true` to just enable it.<br>- Set to a string, to use this string in the usage help text.<br>- Set to a hash containing `label` and `help` keys, to show a detailed help for it when running with `--help`.
206
-
`dependencies` | Specify an array of any required external dependencies (commands). The script execution will be halted with a friendly error unless all dependency commands exist.
207
-
`group` | In case you have many commands, use this option to specify a caption to display before this command. This option is purely for display purposes, and needs to be specified only for the first command in each group.
208
-
`footer` | Add a custom message that will be displayed at the end of the `--help` text.
209
-
210
-
### Argument options
211
-
212
-
The argument's value will be available to you as `${args[user]}` in your
213
-
bash function.
214
-
215
-
Option | Description
216
-
-----------|-------------
217
-
`name` | The name of the argument.
218
-
`help` | The message to display when using `--help`. Can have multiple lines.
219
-
`required` | Specify if this argument is required. Note that once you define an optional argument (without required: true) then you cannot define required arguments after it.
220
-
`default` | The value to use in case it is not provided by the user. Implies that this argument is optional.
221
-
`allowed` | Limit the allowed values by providing an array.
222
-
223
-
### Flag options
224
-
225
-
The flag's value will be available to you as `${args[--output]}` in your
226
-
bash function (regardless of whether the user provided it with the long or
227
-
short form).
228
-
229
-
Option | Description
230
-
-----------|-------------
231
-
`long` | The long form of the flag.
232
-
`short` | The short form of the flag.
233
-
`help` | The text to display when using `--help`. Can have multiple lines.
234
-
`arg` | If the flag requires an argument, specify its name here.
235
-
`required` | Specify if this flag is required.
236
-
`default` | The value to use in case it is not provided by the user. Implies that this flag is optional, and only makes sense when the flag has an argument.
237
-
`allowed` | For flags with an argument, you can limit the allowed values by providing an array.
238
-
239
-
#### Special handling for -v and -h
240
-
241
-
The `-v` and `-h` flags will be used as the short options for `--version` and
242
-
`--help` respectively **only if you are not using them in any of your own
243
-
flags**.
244
-
245
-
### Environment variable options
246
-
247
-
If an environment variable is defined as required (false by default), the
248
-
execution of the script will be halted with a friendly error if it is not
249
-
set.
250
-
251
-
Option | Description
252
-
-----------|-------------
253
-
`name` | The name of the variable (it will be automatically capitalized).
254
-
`help` | The message to display when using --help. Can have multiple lines.
255
-
`required` | Specify if this variable is required.
256
-
257
-
258
-
## Extensible Scripts
259
-
260
-
You may configure your generated bash script to delegate any unknown command
261
-
to an external executable, by setting the `extensible` option to either `true`,
262
-
or to a different external command.
263
-
264
-
This is similar to how `git` works. When you execute `git whatever`, the `git`
265
-
command will look for a file named `git-whatever` in the path, and execute it.
266
-
267
-
Note that this option cannot be specified together with the `default` option,
268
-
since both specify a handler for unknown commands.
269
-
270
-
The `extensible` option supports two operation modes:
271
-
272
-
### Extension Mode (`extensible: true`)
273
-
274
-
By setting `extensible` to `true`, a specially named executable will be called
275
-
when an unknown command is called by the user.
276
-
277
-
Given this `bashly.yml` configuration:
278
-
279
-
```yaml
280
-
name: myscript
281
-
help: Example
282
-
version: 0.1.0
283
-
extensible: true
284
-
285
-
commands:
286
-
- name: upload
287
-
help: Upload a file
288
-
```
289
-
290
-
And this user command:
291
-
292
-
```
293
-
$ myscript something
294
-
295
-
```
296
-
297
-
The generated script will look for an executable named `myscript-something`
298
-
in the path. If found, it will be called.
299
-
300
-
See the [extensible example](examples/extensible).
0 commit comments