Skip to content

Commit 11c07a0

Browse files
author
François Chastanet
committed
Options2 - commit as is
1 parent 6788062 commit 11c07a0

18 files changed

Lines changed: 88 additions & 160 deletions

manualTests/Object::create.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ source "${srcDir}/Options2/__all.sh"
1111
# shellcheck source=/src/Log/__all.sh
1212
source "${srcDir}/Log/__all.sh"
1313

14-
1514
#set -x
1615
set -o errexit
1716
set -o pipefail
@@ -22,17 +21,18 @@ Object::create zzzGroupGlobalOptionsFunction \
2221
--property-title "GLOBAL OPTIONS:"
2322

2423
Object::create simpleObjectFunction \
25-
--type "Group"
24+
--type "Group"
2625

2726
Object::create groupObjectFunction \
28-
--type "Group" \
29-
--property-title "title" \
30-
--property-help "help"
27+
--type "Group" \
28+
--property-title "title" \
29+
--property-help "help"
3130

3231
BASH_FRAMEWORK_DISPLAY_LEVEL=__LEVEL_DEBUG
3332

3433
Object::create optionFunction \
3534
--type "Option" \
3635
--property-variableName "varName"
3736

38-
Options2::validateOptionObject "${optionFunction}"
37+
# shellcheck disable=SC2154
38+
Options2::validateOptionObject "${optionFunction}"

manualTests/Object::setProperty.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ declare -a newPropertyObject=(
1616
--property-property "propertyValue"
1717
)
1818
Object::setProperty newPropertyObject --property-newProperty "value"
19-
declare -p newPropertyObject
19+
declare -p newPropertyObject

manualTests/Options2::renderHelpArg.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ declare -a arg=(
2626
--property-mandatory 1
2727
--property-max 2
2828
)
29+
# shellcheck disable=SC2034
2930
declare -a group=(
3031
--type "Group"
3132
--property-title "Global options"
@@ -42,4 +43,4 @@ declare -a arg=(
4243
)
4344
Options2::validateArgObject arg
4445
UI::theme "default"
45-
Options2::renderArgHelp arg 2>&1
46+
Options2::renderArgHelp arg 2>&1

manualTests/testCreateObject.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ source src/Options2/__all.sh
77

88
declare myFunction
99
Object::create myFunction \
10-
--type "Command" \
11-
--property-name "François"
10+
--type "Command" \
11+
--property-name "François"
1212
declare myFunction2
1313
Object::create myFunction2 \
14-
--array-list "a" \
15-
--type "Command2" \
16-
--property-name "François2" \
17-
--array-list "b" \
18-
--array-list "c"
14+
--array-list "a" \
15+
--type "Command2" \
16+
--property-name "François2" \
17+
--array-list "b" \
18+
--array-list "c"
1919

2020
echo "--------------------------------------------"
2121
${myFunction} getProperty --property-name
@@ -30,12 +30,12 @@ ${myFunction2} setProperty name "myFunction2François3"
3030
${myFunction2} getProperty --property-name
3131
echo -n "name2 "
3232
${myFunction2} setProperty name2 "newProperty name2"
33-
33+
3434
${myFunction2} getProperty --property-name2
3535

3636
echo "--------------------------------------------"
3737
Object::create myFunction2 \
38-
--function-name "argFunction2Overload" \
39-
--type "Command2Overload" \
40-
--property-name "François2Overload"
41-
${myFunction2} getProperty --property-name
38+
--function-name "argFunction2Overload" \
39+
--type "Command2Overload" \
40+
--property-name "François2Overload"
41+
${myFunction2} getProperty --property-name

src/Object/create.bats

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function Object::create::simpleObject { #@test
1616
Object::create simpleObjectFunction \
1717
--type "simpleObjectType" \
1818
--property-property "propertyValue"
19-
19+
2020
run ${simpleObjectFunction} type
2121
assert_output "simpleObjectType"
2222

@@ -43,7 +43,7 @@ function Object::create::missingPositionalArg { #@test
4343
run Object::create \
4444
--type "simpleObjectType" \
4545
--propertyInvalid-property "propertyValue" 2>&1
46-
46+
4747
assert_output --partial "local: \`--type': invalid variable name for name reference"
4848
assert_failure 1
4949
}
@@ -54,7 +54,7 @@ function Object::create::simpleObjectNonStrict { #@test
5454
--strict 0 \
5555
--type "simpleObjectType" \
5656
--property-property "propertyValue"
57-
57+
5858
run ${simpleObjectType} strict
5959
assert_output "0"
6060

@@ -68,7 +68,7 @@ function Object::create::invalidProperty { #@test
6868
run Object::create simpleObjectType \
6969
--type "simpleObjectType" \
7070
--propertyInvalid-property "propertyValue" 2>&1
71-
71+
7272
assert_output --partial "ERROR - invalid object property --propertyInvalid-property"
7373
assert_failure 1
7474
}
@@ -79,25 +79,25 @@ function Object::create::duplicatedProperty { #@test
7979
--type "simpleObjectType" \
8080
--property-property "propertyValue1" \
8181
--property-property "propertyValue2" 2>&1
82-
82+
8383
assert_output --partial "ERROR - property property is provided more than one time"
8484
assert_failure 1
8585
}
8686

8787
function Object::create::invalidObjectType { #@test
88-
declare invalidObjectType
88+
declare invalidObjectType
8989
run Object::create invalidObjectType \
9090
--type "invalidéObjectType" \
9191
--property-property "propertyValue" 2>&1
92-
92+
9393
assert_output --partial "ERROR - invalid object type invalidéObjectType"
9494
assert_failure 1
9595
}
9696

9797
function Object::create::missingObjectType { #@test
9898
run Object::create missingObjectType \
9999
--property-property "propertyValue" 2>&1
100-
100+
101101
assert_output --partial "ERROR - missing object type"
102102
assert_failure 1
103103
}
@@ -107,9 +107,9 @@ function Object::create::unknownArray { #@test
107107
Object::create unknownArray \
108108
--type "simpleObjectType" \
109109
--array-list "unknownArray" 2>&1
110-
110+
111111
run ${unknownArray} getArray "unknownArray"
112-
112+
113113
assert_output --partial "ERROR - unknown array unknownArray"
114114
assert_failure 2
115115
}
@@ -121,7 +121,7 @@ function Object::create::propertyArrayOrdered { #@test
121121
--property-property "propertyValue" \
122122
--array-list "value1" \
123123
--array-list "value2"
124-
124+
125125
run ${propertyArrayOrdered} type
126126
assert_success
127127
assert_output "simpleObjectType"
@@ -148,7 +148,7 @@ function Object::create::propertyArrayUnordered { #@test
148148
--array-list "value2" \
149149
--property-property "propertyValue" \
150150
--array-list "value3"
151-
151+
152152
run ${propertyArrayUnordered} type
153153
assert_success
154154
assert_output "simpleObjectType"
@@ -172,4 +172,4 @@ function Object::create::propertyArrayUnordered { #@test
172172
assert_lines_count 2
173173
assert_line --index 0 "list"
174174
assert_line --index 1 "property"
175-
}
175+
}

src/Object/getArray.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ function Object::getArray::multipleArrayValues { #@test
4444
assert_success
4545
}
4646

47-
function Object::getArray::unknownProperty { #@test
47+
function Object::getArray::unknownArray { #@test
4848
declare -a simpleObject=(
4949
--type "simpleObjectType"
5050
--property-property "propertyValue"
5151
)
5252
run Object::getArray simpleObject --array-unknownArray 1
53-
assert_output --partial "ERROR - unknown array --array-unknownArray"
53+
assert_output ""
5454
assert_failure 1
5555

5656
run Object::getArray simpleObject --array-unknownArray 0

src/Object/getArray.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/bin/bash
22

3+
# @description get array elements from object
4+
# @arg $1 object_get_array_objectData:&String[] the object
5+
# @arg $2 arrayName:String the name of the array property to search (eg: --array-property)
6+
# @arg $3 strict:Boolean if !0 then return code 1 if array property not found
7+
# @stdout the array property values if array property found(one value by line)
8+
# @exitcode 1 if array property not found
39
Object::getArray() {
410
local -n object_get_array_objectData=$1
511
local arrayName="${2:-}"

src/Object/getProperty.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function Object::getProperty::unknownProperty { #@test
3131
--property-property "propertyValue"
3232
)
3333
run Object::getProperty simpleObject --property-unknownProperty 1
34-
assert_output --partial "ERROR - unknown property --property-unknownProperty"
34+
assert_output ""
3535
assert_failure 1
3636

3737
run Object::getProperty simpleObject --property-unknownProperty 0

src/Object/getProperty.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/bin/bash
22

3+
# @description get property value from object
4+
# @arg $1 object_get_property_objectData:&String[] the object
5+
# @arg $2 propertyName:String the name of the property to search (eg: --property)
6+
# @arg $3 strict:Boolean if !0 then return code 1 if property not found
7+
# @stdout the property value if property found
8+
# @exitcode 1 if property not found
39
Object::getProperty() {
410
local -n object_get_property_objectData=$1
511
local propertyName="${2:-}"

src/Object/initFromTemplate.bats

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)