Skip to content

Commit 6571f9d

Browse files
author
Matt Pearson
committed
Add '-h', '--help'.
1 parent f920e3f commit 6571f9d

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

deploy.sh

+41-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,42 @@
11
#!/usr/bin/env bash
22
set -o errexit #abort if any command fails
3+
me=$(basename "$0")
4+
5+
read -r -d '' "help_message" <<EOF || true
6+
7+
Deploy generated files to a git branch.
8+
9+
Usage:
10+
11+
$me [<options>]
12+
13+
Options:
14+
15+
-h, --help Show this help information.
16+
-v, --verbose Increase verbosity. Useful for debugging.
17+
-e, --allow-empty Allow deployment of an empty directory.
18+
-m, --message MESSAGE Specify the message used when committing on the
19+
deploy branch.
20+
-n, --no-hash Don't append the source commit's hash to the deploy
21+
commit's message.
22+
-c, --config-file PATH Override default & environment variables' values
23+
with those in set in the file at 'PATH'.
24+
25+
Variables:
26+
27+
* GIT_DEPLOY_DIR Folder path containing the files to deploy.
28+
* GIT_DEPLOY_BRANCH Commit deployable files to this branch.
29+
* GIT_DEPLOY_REPO Push the deploy branch to this repository.
30+
31+
These variables have default values defined in the script. The defaults can be
32+
overridden by environment variables. Any environment variables are overridden
33+
by values set in a '.env' file (if it exists), and in turn by those set in a
34+
file specified by the '--config-file' option.
35+
EOF
36+
37+
print_help() {
38+
printf "%s\n" "$help_message"
39+
}
340

441
main() {
542
# Set args from a local environment file.
@@ -12,7 +49,10 @@ main() {
1249

1350
# Parse arg flags
1451
while : ; do
15-
if [[ $1 = "-v" || $1 = "--verbose" ]]; then
52+
if [[ $1 = "-h" || $1 = "--help" ]]; then
53+
print_help
54+
return 0
55+
elif [[ $1 = "-v" || $1 = "--verbose" ]]; then
1656
verbose=true
1757
shift
1858
elif [[ $1 = "-e" || $1 = "--allow-empty" ]]; then

readme.md

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ You can also define any of variables using environment variables and configurati
1717
- `GIT_DEPLOY_DIR`
1818
- `GIT_DEPLOY_BRANCH`
1919
- `GIT_DEPLOY_REPO`
20+
- `GIT_DEPLOY_APPEND_HASH`
2021

2122
The script will set these variables in this order of preference:
2223

@@ -37,6 +38,8 @@ Do this every time you want to deploy, or have your CI server do it.
3738
5. run `./deploy.sh`
3839

3940
### options
41+
`-h`, `--help`: show the program's help info.
42+
4043
`-c`, `--config-file`: specify a file that overrides the script's default configuration, or those values set in `.env`. The syntax for this file should be normal `var=value` declarations.
4144

4245
`-m`, `--message <message>`: specify message to be used for the commit on `deploy_branch`. By default, the message is the title of the source commit, prepended with 'publish: '.

0 commit comments

Comments
 (0)