Skip to content

Commit a85c753

Browse files
authored
Fix #74
1 parent 65e1308 commit a85c753

File tree

7 files changed

+62
-3
lines changed

7 files changed

+62
-3
lines changed

lib/bashly/views/command/usage.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
printf "<%= strings[:options] %>\n"
3838
<%= render(:usage_fixed_flags).indent 4 %>
3939
<%= render(:usage_flags).indent 4 if flags.any? %>
40-
<%= render(:usage_args).indent 4 if args.any? %>
40+
<%= render(:usage_args).indent 4 if args.any? or catch_all_help %>
4141
<%= render(:usage_environment_variables).indent 4 if environment_variables.any? %>
4242
<%= render(:usage_examples).indent 4 if examples %>
4343

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# :command.usage_args
22
printf "<%= strings[:arguments] %>\n"
3+
<%- if args.any? -%>
34

45
<%- args.each do |arg| -%>
56
<%= arg.render(:usage) %>
67
<%- end -%>
7-
8+
<%- end -%>
89
<%- if catch_all_help -%>
10+
911
echo " <%= catch_all_label %>"
1012
printf "<%= catch_all_help.wrap(76).indent(4).sanitize_for_print %>\n"
1113
echo
12-
<%- end -%>
14+
<%- end -%>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
+ bashly generate
2+
creating user files in src
3+
created src/initialize.sh
4+
created src/root_command.sh
5+
created ./download
6+
run ./download --help to test your bash script
7+
+ ./download
8+
# this file is located in 'src/root_command.sh'
9+
# you can edit it freely and regenerate (it will not be overwritten)
10+
args: none
11+
+ ./download --help
12+
download - Download something
13+
14+
Usage:
15+
download [URLS...]
16+
download --help | -h
17+
download --version | -v
18+
19+
Options:
20+
--help, -h
21+
Show this help
22+
23+
--version, -v
24+
Show version number
25+
26+
Arguments:
27+
URLS...
28+
List of URLs
29+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
download
2+
src/*.sh
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This fixture tests that catch all with help is displayed even when the
2+
configuration file does not have any args defined.
3+
Reference issue: https://github.com/DannyBen/bashly/issues/74
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: download
2+
help: Download something
3+
version: 0.1.0
4+
5+
catch_all:
6+
label: "URLs"
7+
help: "List of URLs"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
# This fixture tests that catch all with help is displayed even when the
4+
# configuration file does not have any args defined.
5+
# It is executed as part of the Runfile examples test
6+
# Reference issue: https://github.com/DannyBen/bashly/issues/74
7+
8+
rm -f ./src/*.sh
9+
rm -f ./download
10+
11+
set -x
12+
13+
bashly generate
14+
15+
./download
16+
./download --help

0 commit comments

Comments
 (0)