Skip to content

Commit 370982e

Browse files
committed
- Add support for double dash as an argument parsing terminator
1 parent f659bfc commit 370982e

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

examples/catch-all/src/bashly.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ args:
1010
required: true
1111
help: Message
1212

13+
flags:
14+
- long: --debug
15+
short: -d

examples/catch-all/test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ bashly generate
1111
./download
1212
./download -h
1313
./download something
14-
./download something with --additional args
14+
./download something with --additional args
15+
./download something --debug -- also pass --debug to catch_all

lib/bashly/views/command/parse_requirements_while.gtx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ unless global_flags?
1010
end
1111
end
1212

13+
>
14+
> --)
15+
> shift
16+
> other_args+=("$@")
17+
> break
18+
> ;;
1319
>
1420
> -?*)
1521

spec/approvals/examples/catch-all

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

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

@@ -22,6 +22,9 @@ Options:
2222
--version, -v
2323
Show version number
2424

25+
--debug, -d
26+
27+
2528
Arguments:
2629
MESSAGE
2730
Message
@@ -42,3 +45,17 @@ other_args:
4245
- ${other_args[0]} = with
4346
- ${other_args[1]} = --additional
4447
- ${other_args[2]} = args
48+
+ ./download something --debug -- also pass --debug to catch_all
49+
# this file is located in 'src/root_command.sh'
50+
# you can edit it freely and regenerate (it will not be overwritten)
51+
args:
52+
- ${args[--debug]} = 1
53+
- ${args[message]} = something
54+
55+
other_args:
56+
- ${other_args[*]} = also pass --debug to catch_all
57+
- ${other_args[0]} = also
58+
- ${other_args[1]} = pass
59+
- ${other_args[2]} = --debug
60+
- ${other_args[3]} = to
61+
- ${other_args[4]} = catch_all

0 commit comments

Comments
 (0)