Skip to content

Commit 188dbca

Browse files
authored
Merge pull request #621 from DannyBen/add/example
Add example for `help_header_override`
2 parents afcc02f + aa00c75 commit 188dbca

File tree

10 files changed

+228
-3
lines changed

10 files changed

+228
-3
lines changed

examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Each of these examples demonstrates one aspect or feature of bashly.
5151
- [custom-strings](custom-strings#readme) - configuring the script's error and usage texts
5252
- [custom-includes](custom-includes#readme) - adding and organizing your custom functions
5353
- [custom-script-header](custom-script-header#readme) - configuring a different script header
54+
- [help-header-override](help-header-override#readme) - replacing the header of the help message
5455
- [footer](footer#readme) - adding a footer to the help message
5556
- [command-filenames](command-filenames#readme) - overriding filenames for your source scripts
5657
- [command-paths](command-paths#readme) - configuring nested paths for your source scripts
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
download
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Help Header Override Example
2+
3+
Demonstrates how to fully replace the header in the output of `--help`.
4+
5+
This is especially useful when incorporating ASCII art as your script's help
6+
header.
7+
8+
This example was generated with:
9+
10+
```bash
11+
$ bashly init --minimal
12+
# ... now edit src/bashly.yml to match the example ...
13+
$ bashly generate
14+
15+
```
16+
17+
-----
18+
19+
## `bashly.yml`
20+
21+
````yaml
22+
name: download
23+
help: Sample minimal application without commands
24+
version: 0.1.0
25+
26+
# Use bash code here directly or a function name that references code elsewhere.
27+
help_header_override: |
28+
echo
29+
echo $' 888888b. 888 888 '
30+
echo $' 888 "88b 888 888 '
31+
echo $' 888 .88P 888 888 '
32+
echo $' 8888888K. 8888b. .d8888b 88888b. 888 888 888 '
33+
echo $' 888 "Y88b "88b 88K 888 "88b 888 888 888 '
34+
echo $' 888 888 .d888888 "Y8888b. 888 888 888 888 888 '
35+
echo $' 888 d88P 888 888 X88 888 888 888 Y88b 888 '
36+
echo $' 8888888P" "Y888888 88888P\' 888 888 888 "Y88888 '
37+
echo $' 888 '
38+
echo $' Y8b d88P '
39+
echo $' "Y88P" '
40+
echo
41+
42+
args:
43+
- name: source
44+
help: URL to download from
45+
- name: target
46+
help: "Target filename (default: same as source)"
47+
48+
flags:
49+
- long: --force
50+
short: -f
51+
help: Overwrite existing files
52+
53+
examples:
54+
- download example.com
55+
- download example.com ./output -f
56+
````
57+
58+
59+
60+
## Output
61+
62+
### `$ ./download`
63+
64+
````shell
65+
# This file is located at 'src/root_command.sh'.
66+
# It contains the implementation for the 'download' command.
67+
# The code you write here will be wrapped by a function named 'download_command()'.
68+
# Feel free to edit this file; your changes will persist when regenerating.
69+
args: none
70+
71+
72+
````
73+
74+
### `$ ./download --help`
75+
76+
````shell
77+
78+
888888b. 888 888
79+
888 "88b 888 888
80+
888 .88P 888 888
81+
8888888K. 8888b. .d8888b 88888b. 888 888 888
82+
888 "Y88b "88b 88K 888 "88b 888 888 888
83+
888 888 .d888888 "Y8888b. 888 888 888 888 888
84+
888 d88P 888 888 X88 888 888 888 Y88b 888
85+
8888888P" "Y888888 88888P' 888 888 888 "Y88888
86+
888
87+
Y8b d88P
88+
"Y88P"
89+
90+
Usage:
91+
download [SOURCE] [TARGET] [OPTIONS]
92+
download --help | -h
93+
download --version | -v
94+
95+
Options:
96+
--force, -f
97+
Overwrite existing files
98+
99+
--help, -h
100+
Show this help
101+
102+
--version, -v
103+
Show version number
104+
105+
Arguments:
106+
SOURCE
107+
URL to download from
108+
109+
TARGET
110+
Target filename (default: same as source)
111+
112+
Examples:
113+
download example.com
114+
download example.com ./output -f
115+
116+
117+
118+
````
119+
120+
121+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: download
2+
help: Sample minimal application without commands
3+
version: 0.1.0
4+
5+
# Use bash code here directly or a function name that references code elsewhere.
6+
help_header_override: |
7+
echo
8+
echo $' 888888b. 888 888 '
9+
echo $' 888 "88b 888 888 '
10+
echo $' 888 .88P 888 888 '
11+
echo $' 8888888K. 8888b. .d8888b 88888b. 888 888 888 '
12+
echo $' 888 "Y88b "88b 88K 888 "88b 888 888 888 '
13+
echo $' 888 888 .d888888 "Y8888b. 888 888 888 888 888 '
14+
echo $' 888 d88P 888 888 X88 888 888 888 Y88b 888 '
15+
echo $' 8888888P" "Y888888 88888P\' 888 888 888 "Y88888 '
16+
echo $' 888 '
17+
echo $' Y8b d88P '
18+
echo $' "Y88P" '
19+
echo
20+
21+
args:
22+
- name: source
23+
help: URL to download from
24+
- name: target
25+
help: "Target filename (default: same as source)"
26+
27+
flags:
28+
- long: --force
29+
short: -f
30+
help: Overwrite existing files
31+
32+
examples:
33+
- download example.com
34+
- download example.com ./output -f
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
echo "# This file is located at 'src/root_command.sh'."
2+
echo "# It contains the implementation for the 'download' command."
3+
echo "# The code you write here will be wrapped by a function named 'download_command()'."
4+
echo "# Feel free to edit this file; your changes will persist when regenerating."
5+
inspect_args

examples/help-header-override/test.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
rm -f src/*.sh
4+
5+
set -x
6+
7+
bashly generate
8+
9+
### Try Me ###
10+
11+
./download
12+
./download --help

examples/render-mandoc/docs/download.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" Automatically generated by Pandoc 3.2
22
.\"
3-
.TH "download" "1" "January 2025" "Version 0.1.0" "Sample application"
3+
.TH "download" "1" "February 2025" "Version 0.1.0" "Sample application"
44
.SH NAME
55
\f[B]download\f[R] \- Sample application
66
.SH SYNOPSIS

examples/render-mandoc/docs/download.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% download(1) Version 0.1.0 | Sample application
22
% Lana Lang
3-
% January 2025
3+
% February 2025
44

55
NAME
66
==================================================
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
+ bashly generate
2+
creating user files in src
3+
created src/root_command.sh
4+
created ./download
5+
run ./download --help to test your bash script
6+
+ ./download
7+
# This file is located at 'src/root_command.sh'.
8+
# It contains the implementation for the 'download' command.
9+
# The code you write here will be wrapped by a function named 'download_command()'.
10+
# Feel free to edit this file; your changes will persist when regenerating.
11+
args: none
12+
+ ./download --help
13+
14+
888888b. 888 888
15+
888 "88b 888 888
16+
888 .88P 888 888
17+
8888888K. 8888b. .d8888b 88888b. 888 888 888
18+
888 "Y88b "88b 88K 888 "88b 888 888 888
19+
888 888 .d888888 "Y8888b. 888 888 888 888 888
20+
888 d88P 888 888 X88 888 888 888 Y88b 888
21+
8888888P" "Y888888 88888P' 888 888 888 "Y88888
22+
888
23+
Y8b d88P
24+
"Y88P"
25+
26+
Usage:
27+
download [SOURCE] [TARGET] [OPTIONS]
28+
download --help | -h
29+
download --version | -v
30+
31+
Options:
32+
--force, -f
33+
Overwrite existing files
34+
35+
--help, -h
36+
Show this help
37+
38+
--version, -v
39+
Show version number
40+
41+
Arguments:
42+
SOURCE
43+
URL to download from
44+
45+
TARGET
46+
Target filename (default: same as source)
47+
48+
Examples:
49+
download example.com
50+
download example.com ./output -f
51+

spec/approvals/examples/render-mandoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ ISSUE TRACKER
4444
AUTHORS
4545
Lana Lang.
4646

47-
Version 0.1.0 January 2025 download(1)
47+
Version 0.1.0 February 2025 download(1)

0 commit comments

Comments
 (0)