Skip to content

Commit 57217de

Browse files
authored
Merge pull request #512 from DannyBen/add/double-dash-usage
Add `[--]` to usage text when `catch_all` is used
2 parents 0115c89 + 1422bcf commit 57217de

File tree

14 files changed

+66
-30
lines changed

14 files changed

+66
-30
lines changed

examples/catch-all-advanced/README.md

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ cli download - Download a file
9090
Alias: d
9191

9292
Usage:
93-
cli download SOURCE [TARGET] [OPTIONS] [AWS PARAMS...]
93+
cli download SOURCE [TARGET] [OPTIONS] [--] [AWS PARAMS...]
9494
cli download --help | -h
9595

9696
Options:
@@ -143,21 +143,57 @@ args:
143143

144144
````
145145

146-
### `$ ./cli download source target and --additional stuff`
146+
### `$ ./cli download source target --force`
147147

148148
````shell
149149
# this file is located in 'src/download_command.sh'
150150
# code for 'cli download' goes here
151151
# you can edit it freely and regenerate (it will not be overwritten)
152152
args:
153+
- ${args[--force]} = 1
154+
- ${args[source]} = source
155+
- ${args[target]} = target
156+
157+
158+
````
159+
160+
### `$ ./cli download source target --force -abc --option=value`
161+
162+
````shell
163+
# this file is located in 'src/download_command.sh'
164+
# code for 'cli download' goes here
165+
# you can edit it freely and regenerate (it will not be overwritten)
166+
args:
167+
- ${args[--force]} = 1
168+
- ${args[source]} = source
169+
- ${args[target]} = target
170+
171+
other_args:
172+
- ${other_args[*]} = -a -b -c --option value
173+
- ${other_args[0]} = -a
174+
- ${other_args[1]} = -b
175+
- ${other_args[2]} = -c
176+
- ${other_args[3]} = --option
177+
- ${other_args[4]} = value
178+
179+
180+
````
181+
182+
### `$ ./cli download source target --force -- -abc --option=value`
183+
184+
````shell
185+
# this file is located in 'src/download_command.sh'
186+
# code for 'cli download' goes here
187+
# you can edit it freely and regenerate (it will not be overwritten)
188+
args:
189+
- ${args[--force]} = 1
153190
- ${args[source]} = source
154191
- ${args[target]} = target
155192

156193
other_args:
157-
- ${other_args[*]} = and --additional stuff
158-
- ${other_args[0]} = and
159-
- ${other_args[1]} = --additional
160-
- ${other_args[2]} = stuff
194+
- ${other_args[*]} = -abc --option=value
195+
- ${other_args[0]} = -abc
196+
- ${other_args[1]} = --option=value
161197

162198

163199
````
@@ -170,7 +206,7 @@ cli upload - Upload a file
170206
Alias: u
171207

172208
Usage:
173-
cli upload FILES...
209+
cli upload [--] FILES...
174210
cli upload --help | -h
175211

176212
Options:
@@ -189,7 +225,7 @@ Arguments:
189225

190226
````shell
191227
missing required argument: FILES...
192-
usage: cli upload FILES...
228+
usage: cli upload [--] FILES...
193229

194230

195231
````

examples/catch-all-stdin/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ echo
7474
cli - Sample application
7575

7676
Usage:
77-
cli [OPTIONS] [FILE...]
77+
cli [OPTIONS] [--] [FILE...]
7878
cli --help | -h
7979
cli --version | -v
8080

examples/catch-all/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ flags:
4141

4242
````shell
4343
missing required argument: MESSAGE
44-
usage: download MESSAGE [OPTIONS] [...]
44+
usage: download MESSAGE [OPTIONS] [--] [...]
4545

4646

4747
````
@@ -52,7 +52,7 @@ usage: download MESSAGE [OPTIONS] [...]
5252
download - Catch All Example
5353

5454
Usage:
55-
download MESSAGE [OPTIONS] [...]
55+
download MESSAGE [OPTIONS] [--] [...]
5656
download --help | -h
5757
download --version | -v
5858

lib/bashly/script/catch_all.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def required?
4848
def usage_string
4949
return nil unless enabled?
5050

51-
required? ? label : "[#{label}]"
51+
required? ? "[--] #{label}" : "[--] [#{label}]"
5252
end
5353
end
5454
end

spec/approvals/examples/catch-all

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ created ./download
55
run ./download --help to test your bash script
66
+ ./download
77
missing required argument: MESSAGE
8-
usage: download MESSAGE [OPTIONS] [...]
8+
usage: download MESSAGE [OPTIONS] [--] [...]
99
+ ./download -h
1010
download - Catch All Example
1111

1212
Usage:
13-
download MESSAGE [OPTIONS] [...]
13+
download MESSAGE [OPTIONS] [--] [...]
1414
download --help | -h
1515
download --version | -v
1616

spec/approvals/examples/catch-all-advanced

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cli download - Download a file
2222
Alias: d
2323

2424
Usage:
25-
cli download SOURCE [TARGET] [OPTIONS] [AWS PARAMS...]
25+
cli download SOURCE [TARGET] [OPTIONS] [--] [AWS PARAMS...]
2626
cli download --help | -h
2727

2828
Options:
@@ -102,7 +102,7 @@ cli upload - Upload a file
102102
Alias: u
103103

104104
Usage:
105-
cli upload FILES...
105+
cli upload [--] FILES...
106106
cli upload --help | -h
107107

108108
Options:
@@ -115,7 +115,7 @@ Arguments:
115115

116116
+ ./cli upload
117117
missing required argument: FILES...
118-
usage: cli upload FILES...
118+
usage: cli upload [--] FILES...
119119
+ ./cli upload file1 'file 2' file3
120120
# this file is located in 'src/upload_command.sh'
121121
# code for 'cli upload' goes here

spec/approvals/examples/catch-all-stdin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ run ./cli --help to test your bash script
55
cli - Sample application
66

77
Usage:
8-
cli [OPTIONS] [FILE...]
8+
cli [OPTIONS] [--] [FILE...]
99
cli --help | -h
1010
cli --version | -v
1111

spec/approvals/fixtures/catch-all-no-args

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ args: none
1111
download - Download something
1212

1313
Usage:
14-
download [URLS...]
14+
download [--] [URLS...]
1515
download --help | -h
1616
download --version | -v
1717

spec/approvals/rendering/mandoc/catch-all-advanced/cli-download.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ NAME
1010
SYNOPSIS
1111
==================================================
1212

13-
**cli download** SOURCE [TARGET] [OPTIONS] [AWS PARAMS...]
13+
**cli download** SOURCE [TARGET] [OPTIONS] [--] [AWS PARAMS...]
1414

1515
DESCRIPTION
1616
==================================================

spec/approvals/rendering/mandoc/catch-all-advanced/cli-upload.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ NAME
1010
SYNOPSIS
1111
==================================================
1212

13-
**cli upload** FILES...
13+
**cli upload** [--] FILES...
1414

1515
DESCRIPTION
1616
==================================================

0 commit comments

Comments
 (0)