Skip to content

Commit b673396

Browse files
committed
readme update
1 parent 8927885 commit b673396

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Create beautiful bash scripts from simple YAML configuration
3131
- [Argument options](#argument-options)
3232
- [Flag options](#flag-options)
3333
- [Environment Variable options](#environment-variable-options)
34+
- [Extensible Commands](#extensible-commands)
3435
- [Real World Examples](#real-world-examples)
3536
- [Contributing / Support](#contributing--support)
3637

@@ -203,6 +204,7 @@ command and subcommands (under the `commands` definition).
203204
`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.
204205
`version` | The string to display when using `--version`. *Applicable only in the main command*.
205206
`default` | Setting this to `true` on any command, will cause any unrecognized command line to be passed to this command. *Applicable only in subcommands*.
207+
`extensible` | Specify that this command can be [externally extended](#extensible-commands).
206208
`examples` | Specify an array of examples to show when using `--help`. Each example can have multiple lines.
207209
`environment_variables` | Specify an array of [environment variables](#environment-variable-options) needed by your script.
208210
`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.
@@ -262,6 +264,82 @@ set.
262264
`required` | Specify if this variable is required.
263265

264266

267+
## Extensible Commands
268+
269+
You may configure your generated bash script to delegate any unknown command
270+
to an external executable, by setting the `extensible` option to either `true`,
271+
or to a different external command.
272+
273+
This is simiilar to how `git` works. When you execute `git whatever`, the `git`
274+
command will look for a file named `git-whatever` in the path, and execute it.
275+
276+
Note that this option cannot be specified together with the `default` option,
277+
since both specify a handler for unknown commands.
278+
279+
Bashly supports two operation modes.
280+
281+
### Extension Mode (`extensible: true`)
282+
283+
By setting `extensible` to `true`, a specially named executable will be called
284+
when an unknown command is called by the user.
285+
286+
Given this `bashly.yml` configuration:
287+
288+
```yaml
289+
name: myscript
290+
help: Example
291+
version: 0.1.0
292+
extensible: true
293+
294+
commands:
295+
- name: upload
296+
help: Upload a file
297+
```
298+
299+
And this user command:
300+
301+
```
302+
$ myscript something
303+
304+
```
305+
306+
The generated script will look for an executable named `myscript-something`
307+
in the path. If found, it will be called.
308+
309+
See the [extensible example](examples/extensible)
310+
311+
312+
### Delegate Mode (`extensible: <executable name>`)
313+
314+
By setting `extensible` to any string, unknown command calls by the user will
315+
be delegated to the executable with that name.
316+
317+
Given this `bashly.yml` configuration:
318+
319+
```yaml
320+
name: mygit
321+
help: Example
322+
version: 0.1.0
323+
extensible: git
324+
325+
commands:
326+
- name: push
327+
help: Push to my repository
328+
```
329+
330+
And this user command:
331+
332+
```
333+
$ mygit status
334+
335+
```
336+
337+
The generated script will execute `git status`.
338+
339+
See the [extensible-delegate example](examples/extensible-delegate)
340+
341+
342+
265343
## Real World Examples
266344

267345
- [Rush][rush] - a Personal Package Manager

0 commit comments

Comments
 (0)