File tree Expand file tree Collapse file tree 6 files changed +60
-0
lines changed
fixtures/workspaces/repeatable-arg-validations Expand file tree Collapse file tree 6 files changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ + bundle exec bashly generate
2
+ creating user files in src
3
+ created src/initialize.sh
4
+ created src/root_command.sh
5
+ created ./cli
6
+ run ./cli --help to test your bash script
7
+ + ./cli
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
+ + ./cli 1
12
+ # this file is located in 'src/root_command.sh'
13
+ # you can edit it freely and regenerate (it will not be overwritten)
14
+ args:
15
+ - ${args[number]} = "1"
16
+ + ./cli 1 2
17
+ # this file is located in 'src/root_command.sh'
18
+ # you can edit it freely and regenerate (it will not be overwritten)
19
+ args:
20
+ - ${args[number]} = "1" "2"
21
+ + ./cli 1.1
22
+ validation error in NUMBER:
23
+ must be an integer
24
+ + ./cli 1.1 2
25
+ validation error in NUMBER:
26
+ must be an integer
27
+ + ./cli 1 2.2
28
+ validation error in NUMBER:
29
+ must be an integer
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 validations on repeatable args validate all arguments
2
+ ** regardless of order** .
3
+ Reference issue: https://github.com/DannyBen/bashly/issues/311
Original file line number Diff line number Diff line change
1
+ name : cli
2
+ help : all arguments must be integers
3
+
4
+ args :
5
+ - name : number
6
+ repeatable : true
7
+ validate : integer
Original file line number Diff line number Diff line change
1
+ validate_integer () {
2
+ [[ " $1 " =~ ^[0-9]+$ ]] || echo " must be an integer"
3
+ }
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ rm -f ./cli
4
+ rm -f ./src/initialize.sh
5
+ rm -f ./src/root_command.sh
6
+
7
+ set -x
8
+
9
+ bundle exec bashly generate
10
+
11
+ ./cli
12
+ ./cli 1
13
+ ./cli 1 2
14
+ ./cli 1.1
15
+ ./cli 1.1 2
16
+ ./cli 1 2.2
You can’t perform that action at this time.
0 commit comments