|
| 1 | +# Argfile Example |
| 2 | + |
| 3 | +Demonstrates how to autoload additional arguments from a file using the |
| 4 | +`argfile` command option. |
| 5 | + |
| 6 | +This example was generated with: |
| 7 | + |
| 8 | +```bash |
| 9 | +$ bashly init --minimal |
| 10 | +# ... now edit src/bashly.yml to match the example ... |
| 11 | +# ... now create .download to match the example ... |
| 12 | +$ bashly generate |
| 13 | +``` |
| 14 | + |
| 15 | +<!-- include: .download --> |
| 16 | + |
| 17 | +----- |
| 18 | + |
| 19 | +## `bashly.yml` |
| 20 | + |
| 21 | +````yaml |
| 22 | +name: download |
| 23 | +help: Sample application with autoloaded arguments |
| 24 | +version: 0.1.0 |
| 25 | + |
| 26 | +# Allow users to configure args and flags in a file named '.download' |
| 27 | +argfile: .download |
| 28 | + |
| 29 | +args: |
| 30 | +- name: source |
| 31 | + required: true |
| 32 | + help: URL to download from |
| 33 | + |
| 34 | +flags: |
| 35 | +- long: --force |
| 36 | + short: -f |
| 37 | + help: Overwrite existing files |
| 38 | +- long: --log |
| 39 | + short: -l |
| 40 | + arg: path |
| 41 | + help: Path to log file |
| 42 | +```` |
| 43 | + |
| 44 | +## `.download` |
| 45 | + |
| 46 | +````bash |
| 47 | +--force |
| 48 | +--log "some path with spaces.log" |
| 49 | + |
| 50 | +```` |
| 51 | + |
| 52 | + |
| 53 | +## Output |
| 54 | + |
| 55 | +### `$ ./download somesource` |
| 56 | + |
| 57 | +````shell |
| 58 | +# This file is located at 'src/root_command.sh'. |
| 59 | +# It contains the implementation for the 'download' command. |
| 60 | +# The code you write here will be wrapped by a function named 'root_command()'. |
| 61 | +# Feel free to edit this file; your changes will persist when regenerating. |
| 62 | +args: |
| 63 | +- ${args[--force]} = 1 |
| 64 | +- ${args[--log]} = some path with spaces.log |
| 65 | +- ${args[source]} = somesource |
| 66 | + |
| 67 | + |
| 68 | +```` |
| 69 | + |
| 70 | +### `$ ./download somesource --log cli.log` |
| 71 | + |
| 72 | +````shell |
| 73 | +# This file is located at 'src/root_command.sh'. |
| 74 | +# It contains the implementation for the 'download' command. |
| 75 | +# The code you write here will be wrapped by a function named 'root_command()'. |
| 76 | +# Feel free to edit this file; your changes will persist when regenerating. |
| 77 | +args: |
| 78 | +- ${args[--force]} = 1 |
| 79 | +- ${args[--log]} = cli.log |
| 80 | +- ${args[source]} = somesource |
| 81 | + |
| 82 | + |
| 83 | +```` |
| 84 | + |
| 85 | + |
| 86 | + |
0 commit comments