|
| 1 | +# Command Filenames Example |
| 2 | + |
| 3 | +Demonstrates how to specify custom filenames for command source files. |
| 4 | +This is useful for scripts with many commands, in case you wish to organize |
| 5 | +your source files in sub-folders. |
| 6 | + |
| 7 | +Note that the specified path is relative to the `sec` folder. |
| 8 | + |
| 9 | +This example was generated with: |
| 10 | + |
| 11 | +```bash |
| 12 | +$ bashly init |
| 13 | +# ... now edit src/bashly.yml to match the example ... |
| 14 | +$ bashly generate |
| 15 | +``` |
| 16 | + |
| 17 | +----- |
| 18 | + |
| 19 | +## `bashly.yml` |
| 20 | + |
| 21 | +```yaml |
| 22 | +name: cli |
| 23 | +help: Demonstrate custom command filenames |
| 24 | +version: 0.1.0 |
| 25 | + |
| 26 | +commands: |
| 27 | +- name: dir |
| 28 | + short: d |
| 29 | + help: Directory commands |
| 30 | + |
| 31 | + commands: |
| 32 | + - name: list |
| 33 | + help: Show files in the directory |
| 34 | + |
| 35 | + # Define a custom filename for this command source. |
| 36 | + # This is relative to the `src` directory, and sub-directories will be |
| 37 | + # created as needed. |
| 38 | + filename: dir_commands/list.sh |
| 39 | + |
| 40 | + - name: remove |
| 41 | + help: Remove directory |
| 42 | + filename: dir_commands/remove.sh |
| 43 | + |
| 44 | +- name: file |
| 45 | + short: f |
| 46 | + help: File commands |
| 47 | + |
| 48 | + commands: |
| 49 | + - name: show |
| 50 | + help: Show file contents |
| 51 | + filename: file_commands/show.sh |
| 52 | + |
| 53 | + - name: edit |
| 54 | + help: Edit the file |
| 55 | + filename: file_commands/edit.sh |
| 56 | +``` |
| 57 | +
|
| 58 | +
|
| 59 | +
|
| 60 | +## Generated script output |
| 61 | +
|
| 62 | +### `$ ./cli` |
| 63 | + |
| 64 | +```shell |
| 65 | +cli - Demonstrate custom command filenames |
| 66 | +
|
| 67 | +Usage: |
| 68 | + cli [command] |
| 69 | + cli [command] --help | -h |
| 70 | + cli --version | -v |
| 71 | +
|
| 72 | +Commands: |
| 73 | + dir Directory commands |
| 74 | + file File commands |
| 75 | +
|
| 76 | +
|
| 77 | +
|
| 78 | +``` |
| 79 | + |
| 80 | +### `$ ./cli -h` |
| 81 | + |
| 82 | +```shell |
| 83 | +cli - Demonstrate custom command filenames |
| 84 | +
|
| 85 | +Usage: |
| 86 | + cli [command] |
| 87 | + cli [command] --help | -h |
| 88 | + cli --version | -v |
| 89 | +
|
| 90 | +Commands: |
| 91 | + dir Directory commands |
| 92 | + file File commands |
| 93 | +
|
| 94 | +Options: |
| 95 | + --help, -h |
| 96 | + Show this help |
| 97 | +
|
| 98 | + --version, -v |
| 99 | + Show version number |
| 100 | +
|
| 101 | +
|
| 102 | +
|
| 103 | +``` |
| 104 | + |
| 105 | +### `$ ./cli dir list` |
| 106 | + |
| 107 | +```shell |
| 108 | +# this file is located in 'src/dir_commands/list.sh' |
| 109 | +# code for 'cli dir list' goes here |
| 110 | +# you can edit it freely and regenerate (it will not be overwritten) |
| 111 | +args: none |
| 112 | +
|
| 113 | +
|
| 114 | +``` |
| 115 | + |
| 116 | + |
| 117 | + |
0 commit comments