File tree Expand file tree Collapse file tree 7 files changed +53
-2
lines changed
fixtures/workspaces/short-flag Expand file tree Collapse file tree 7 files changed +53
-2
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ if default_args.any? or default_flags.any?
6
6
end
7
7
8
8
default_flags.each do |flag|
9
- > [[ -n ${args['{{ flag.long }}']:-} ]] || args['{{ flag.long }}']="{{ flag.default }}"
9
+ > [[ -n ${args['{{ flag.name }}']:-} ]] || args['{{ flag.name }}']="{{ flag.default }}"
10
10
end
11
11
12
12
>
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ if required_flags.any?
2
2
= view_marker
3
3
4
4
required_flags.each do |flag|
5
- > if [[ -z ${args['{{ flag.long }}']+x} ]]; then
5
+ > if [[ -z ${args['{{ flag.name }}']+x} ]]; then
6
6
> printf "{{ strings[:missing_required_flag] % { usage: flag.usage_string } }}\n" >&2
7
7
> exit 1
8
8
> fi
Original file line number Diff line number Diff line change
1
+ + bundle exec bashly generate
2
+ creating user files in src
3
+ created src/root_command.sh
4
+ created ./cli
5
+ run ./cli --help to test your bash script
6
+ + ./cli
7
+ missing required flag: -o PATH
8
+ + ./cli -o /tmp
9
+ # this file is located in 'src/root_command.sh'
10
+ # you can edit it freely and regenerate (it will not be overwritten)
11
+ args:
12
+ - ${args[-f]} = html
13
+ - ${args[-o]} = /tmp
14
+ + ./cli -o /tmp -f json
15
+ # this file is located in 'src/root_command.sh'
16
+ # you can edit it freely and regenerate (it will not be overwritten)
17
+ args:
18
+ - ${args[-f]} = json
19
+ - ${args[-o]} = /tmp
Original file line number Diff line number Diff line change
1
+ cli
2
+ src /* .sh
Original file line number Diff line number Diff line change
1
+ This fixture tests that short flags default and required work properly
2
+ Reference issue: https://github.com/DannyBen/bashly/issues/373
Original file line number Diff line number Diff line change
1
+ name : cli
2
+
3
+ flags :
4
+ - short : -f
5
+ arg : format
6
+ help : Set format
7
+ default : html
8
+
9
+ - short : -o
10
+ arg : path
11
+ help : Output to path
12
+ required : true
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # This fixture tests that alias command codes work properly
4
+ # It is executed as part of the Runfile examples test
5
+ # Reference issue: https://github.com/DannyBen/bashly/issues/16
6
+
7
+ rm -f ./src/* .sh
8
+ rm -f ./cli
9
+
10
+ set -x
11
+
12
+ bundle exec bashly generate
13
+
14
+ ./cli
15
+ ./cli -o /tmp
16
+ ./cli -o /tmp -f json
You can’t perform that action at this time.
0 commit comments