File tree Expand file tree Collapse file tree 4 files changed +16
-11
lines changed Expand file tree Collapse file tree 4 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -3,4 +3,4 @@ if [[ -n $(validate_<%= validation_function %> "$1") ]]; then
3
3
printf "<%= strings[:validation_error] %> \n" "<%= name.upcase %> $(validate_<%= validation_function %> "$1")"
4
4
exit 1
5
5
fi
6
- % end
6
+ % end
Original file line number Diff line number Diff line change 2
2
% if args.any?
3
3
% condition = "if"
4
4
% args.each do |arg|
5
- <%= condition %> [[ ! ${args[<%= arg.name %> ]} ]]; then
5
+ <%= condition %> [[ -z ${args[<%= arg.name %> ]+x } ]]; then
6
6
<%= arg.render(:validations).indent 2 %>
7
7
args[<%= arg.name %> ]=$1
8
8
shift
Original file line number Diff line number Diff line change @@ -3,4 +3,4 @@ if [[ -n $(validate_<%= validation_function %> "$2") ]]; then
3
3
printf "<%= strings[:validation_error] %> \n" "<%= usage_string %> $(validate_<%= validation_function %> "$2")"
4
4
exit 1
5
5
fi
6
- % end
6
+ % end
Original file line number Diff line number Diff line change @@ -3,15 +3,20 @@ skipped src/initialize.sh (exists)
3
3
skipped src/test_command.sh (exists)
4
4
created ./cli
5
5
run ./cli --help to test your bash script
6
+ + ./cli test a b --flag c
7
+ args:
8
+ - ${args[--flag]} = c
9
+ - ${args[optional_arg]} = b
10
+ - ${args[required_arg]} = a
6
11
+ ./cli test ''
7
- # this file is located in 'src/test_command.sh'
8
- # code for 'cli test' goes here
9
- # you can edit it freely and regenerate (it will not be overwritten)
10
12
args:
11
- - ${args[arg]} =
12
- + ./cli test --flag ''
13
- # this file is located in 'src/test_command.sh'
14
- # code for 'cli test' goes here
15
- # you can edit it freely and regenerate (it will not be overwritten)
13
+ - ${args[required_arg]} =
14
+ + ./cli test '' --flag ''
15
+ args:
16
+ - ${args[--flag]} =
17
+ - ${args[required_arg]} =
18
+ + ./cli test '' '' --flag ''
16
19
args:
17
20
- ${args[--flag]} =
21
+ - ${args[optional_arg]} =
22
+ - ${args[required_arg]} =
You can’t perform that action at this time.
0 commit comments