Demonstrates how to customize bashly's error strings and usage string templates.
This example was generated with:
$ bashly init --minimal
$ bashly add strings
$ bashly generate
Running the bashly add strings
command, simply generates the strings
configuration file in src/bashly-strings.yml. You may
edit this file and regenerate your script in order to replace the format of
any (or all) help messages and error messages.
Note that you may delete any of the generated string values completely if you do not wish to change them.
name: download
help: Sample minimal application with custom strings
version: 0.1.0
args:
- name: source
required: true
help: URL to download from
flags:
- long: --out
short: -o
arg: dir
required: true
help: Target directory
# Usage captions
usage: "== Usage =="
options: "== Options =="
arguments: "== Arguments =="
commands: "== Commands =="
# Fixed flags help text
help_flag_text: Show this helpful help
version_flag_text: Show version number
# Error messages
flag_requires_an_argument: "Hey! the flag %{name} requires an argument: %{usage}"
missing_required_argument: "Boom! a required argument is missing: %{arg}\\nusage: %{usage}"
missing_required_flag: "Yo! you forgot a flag: %{usage}"
Boom! a required argument is missing: SOURCE
usage: download SOURCE [OPTIONS]
download - Sample minimal application with custom strings
== Usage ==
download SOURCE [OPTIONS]
download --help | -h
download --version | -v
== Options ==
--out, -o DIR (required)
Target directory
--help, -h
Show this helpful help
--version, -v
Show version number
== Arguments ==
SOURCE
URL to download from
Yo! you forgot a flag: --out, -o DIR
Hey! the flag --out requires an argument: --out, -o DIR