Skip to content

Commit f89e832

Browse files
committed
refactor: Make "namespace" of project consistent to "btoml"
This makes it consistent with bash-object
1 parent 57d0dad commit f89e832

File tree

8 files changed

+43
-43
lines changed

8 files changed

+43
-43
lines changed

pkg/src/public/bash-toml-quick.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# shellcheck shell=bash
22

3-
toml.quick_string_get() {
3+
btoml.quick_string_get() {
44
unset REPLY; REPLY=
55
local toml_file="$1"
66
local key_name="$2"
77

88
if [ ! -f "$toml_file" ]; then
9-
bash_toml.error "File '$toml_file' not found"
9+
btoml.error "File '$toml_file' not found"
1010
return 1
1111
fi
1212

@@ -33,12 +33,12 @@ toml.quick_string_get() {
3333
REPLY="${BASH_REMATCH[1]}"
3434
else
3535
# This should not happen due to the '[[ $line == *"$key_name"*=* ]]' check above
36-
bash_toml.error "Could not find key '$key_name' in file '$toml_file'"
36+
btoml.error "Could not find key '$key_name' in file '$toml_file'"
3737
return 1
3838
fi
3939
}
4040

41-
toml.quick_array_get() {
41+
btoml.quick_array_get() {
4242
unset REPLIES; declare -ga REPLIES=()
4343
local toml_file="$1"
4444
local key_name="$2"
@@ -47,7 +47,7 @@ toml.quick_array_get() {
4747
# ensure.nonzero 'key_name'
4848

4949
if [ ! -f "$toml_file" ]; then
50-
bash_toml.error "File '$toml_file' does not exist"
50+
btoml.error "File '$toml_file' does not exist"
5151
return 2
5252
fi
5353

@@ -98,33 +98,33 @@ toml.quick_array_get() {
9898
if [[ ${REPLIES[$i]} =~ $regex ]]; then
9999
REPLIES[$i]="${BASH_REMATCH[1]}"
100100
else
101-
bash_toml.error "Key '$key_name' in file '$toml_file' is not valid"
101+
btoml.error "Key '$key_name' in file '$toml_file' is not valid"
102102
return 2
103103
fi
104104
done
105105
else
106-
bash_toml.error "Key '$key_name' in file '$toml_file' must be set to an array that spans one line"
106+
btoml.error "Key '$key_name' in file '$toml_file' must be set to an array that spans one line"
107107
return 2
108108
fi
109109
}
110110

111-
toml.quick_array_append() {
111+
btoml.quick_array_append() {
112112
local toml_file="$1"
113113
local key_value="$2"
114114

115115
# ensure.nonzero 'toml_file'
116116
# ensure.nonzero 'key_value'
117117

118118
if [ ! -f "$toml_file" ]; then
119-
bash_toml.error "File '$toml_file' does not exist"
119+
btoml.error "File '$toml_file' does not exist"
120120
return 2
121121
fi
122122

123123
if util.get_toml_array "$toml_file" 'dependencies'; then
124124
local name=
125125
for name in "${REPLIES[@]}"; do
126126
if [ "${name%@*}" = "${key_value%@*}" ]; then
127-
bash_toml.error "A version of '${name%@*}' is already installed. Skipping"
127+
btoml.error "A version of '${name%@*}' is already installed. Skipping"
128128
return 2
129129
fi
130130
done; unset name
@@ -139,20 +139,20 @@ toml.quick_array_append() {
139139
rm "$toml_file.bak"
140140
fi
141141
else
142-
bash_toml.error "Key 'dependencies' not found in file '$toml_file'"
142+
btoml.error "Key 'dependencies' not found in file '$toml_file'"
143143
return 2
144144
fi
145145
}
146146

147-
toml.quick_array_remove() {
147+
btoml.quick_array_remove() {
148148
local toml_file="$1"
149149
local key_value="$2"
150150

151151
# ensure.nonzero 'toml_file'
152152
# ensure.nonzero 'key_value'
153153

154154
if [ ! -f "$toml_file" ]; then
155-
bash_toml.error "File '$toml_file' does not exist"
155+
btoml.error "File '$toml_file' does not exist"
156156
return 2
157157
fi
158158

@@ -169,7 +169,7 @@ toml.quick_array_remove() {
169169
done; unset -v name
170170

171171
if [ "$does_exist" != 'yes' ]; then
172-
bash_toml.error "The package '$key_value' is not currently a dependency"
172+
btoml.error "The package '$key_value' is not currently a dependency"
173173
return 2
174174
fi
175175

@@ -190,7 +190,7 @@ toml.quick_array_remove() {
190190
done < "$toml_file.bak" > "$toml_file"
191191
rm "$toml_file.bak"
192192
else
193-
bash_toml.error "Key 'dependencies' not found in file '$toml_file'"
193+
btoml.error "Key 'dependencies' not found in file '$toml_file'"
194194
return 2
195195
fi
196196
}

pkg/src/util/init_append.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# shellcheck shell=bash
22

3-
bash_toml.init_key_string() {
3+
btoml.init_key_string() {
44
BASH_TOML_KEY_STRING="$1"
55
}
66

7-
bash_toml.append_key_string() {
7+
btoml.append_key_string() {
88
BASH_TOML_KEY_STRING+="$1"
99
}
1010

11-
bash_toml.init_value_string() {
11+
btoml.init_value_string() {
1212
BASH_TOML_KEY_VALUE_STRING=
1313
}
1414

15-
bash_toml.append_value_string() {
15+
btoml.append_value_string() {
1616
BASH_TOML_KEY_VALUE_STRING+="$1"
1717
}

pkg/src/util/is.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
# shellcheck shell=bash
22

3-
bash_toml.is.whitespace() {
3+
btoml.is.whitespace() {
44
if [[ "$1" == @($'\u0009'|$'\u0020') ]]; then
55
return 0
66
else
77
return 1
88
fi
99
}
1010

11-
bash_toml.is.newline() {
11+
btoml.is.newline() {
1212
if [[ "$1" == @($'\u000A'|$'\u0D0A') ]]; then
1313
return 0
1414
else
1515
return 1
1616
fi
1717
}
1818

19-
bash_toml.is.table() {
19+
btoml.is.table() {
2020
if [[ "$1" == \[ ]]; then
2121
return 0
2222
else
2323
return 1
2424
fi
2525
}
2626

27-
bash_toml.is.double_quote() {
27+
btoml.is.double_quote() {
2828
if [[ "$1" == \" ]]; then
2929
return 0
3030
else
3131
return 1
3232
fi
3333
}
3434

35-
bash_toml.is.single_quote() {
35+
btoml.is.single_quote() {
3636
if [[ "$1" == \' ]]; then
3737
return 0
3838
else
3939
return 1
4040
fi
4141
}
4242

43-
bash_toml.is.backslash() {
43+
btoml.is.backslash() {
4444
# shellcheck disable=SC1003
4545
if [[ "$1" == \\ ]]; then
4646
return 0
@@ -49,7 +49,7 @@ bash_toml.is.backslash() {
4949
fi
5050
}
5151

52-
bash_toml.is.control_character() {
52+
btoml.is.control_character() {
5353
# shellcheck disable=SC1003
5454
if [[ "$1" == [[:cntrl:]] ]]; then
5555
return 0
@@ -58,7 +58,7 @@ bash_toml.is.control_character() {
5858
fi
5959
}
6060

61-
bash_toml.is.hex_digit() {
61+
btoml.is.hex_digit() {
6262
# shellcheck disable=SC1003
6363
if [[ "$1" == [[:xdigit:]] ]]; then
6464
return 0
@@ -67,7 +67,7 @@ bash_toml.is.hex_digit() {
6767
fi
6868
}
6969

70-
bash_toml.is.octothorp() {
70+
btoml.is.octothorp() {
7171
# shellcheck disable=SC1003
7272
if [[ "$1" == \# ]]; then
7373
return 0
@@ -76,15 +76,15 @@ bash_toml.is.octothorp() {
7676
fi
7777
}
7878

79-
bash_toml.is.valid_bare_key_char() {
79+
btoml.is.valid_bare_key_char() {
8080
if [[ "$1" == [A-Za-z0-9_-] ]]; then
8181
return 0
8282
else
8383
return 1
8484
fi
8585
}
8686

87-
bash_toml.is.equals_sign() {
87+
btoml.is.equals_sign() {
8888
if [[ "$1" == = ]]; then
8989
return 0
9090
else

pkg/src/util/util.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ declare -gA BASH_TOML_ERRORS=(
1717
declare -a BASH_TOKEN_HISTORY=()
1818

1919
# @description Appends to token history for improved error insight
20-
bash_toml.token_history_add() {
20+
btoml.token_history_add() {
2121
local str=
2222
printf -v str '%s' "$mode ($char) at $PARSER_LINE_NUMBER:$PARSER_COLUMN_NUMBER"
2323

@@ -32,7 +32,7 @@ bash_toml.token_history_add() {
3232
fi
3333
}
3434

35-
bash_toml.parse_fail() {
35+
btoml.parse_fail() {
3636
local error_key="$1"
3737
local error_context="$2"
3838

@@ -62,6 +62,6 @@ bash_toml.parse_fail() {
6262
fi
6363
}
6464

65-
bash_toml.error() {
65+
btoml.error() {
6666
printf '%s\n' "Error: $1" >&2
6767
}

scripts/linter.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# shellcheck shell=bash
22

3-
file='./pkg/lib/cmd/bash-toml.sh'
4-
grep -n -B0 -A1 -e 'bash_toml.parse_fail' "$file" \
3+
file='./pkg/lib/cmd/bash-btoml.sh'
4+
grep -n -B0 -A1 -e 'btoml.parse_fail' "$file" \
55
| grep -vP '(^[0-9]*:|^--$)' \
66
| awk '
77
BEGIN {

tests/quick-array.bats

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
load './util/init.sh'
44

55
@test "Quick array properly fails" {
6-
run toml.quick_array_get "$BASALT_PACKAGE_DIR/tests/testdata/array/file1.toml" \
6+
run btoml.quick_array_get "$BASALT_PACKAGE_DIR/tests/testdata/array/file1.toml" \
77
'badkey'
88

99
assert_failure
1010
}
1111

1212
@test "Quick array get" {
1313
for n in {1..7}; do
14-
toml.quick_array_get "$BASALT_PACKAGE_DIR/tests/testdata/array/file1.toml" \
14+
btoml.quick_array_get "$BASALT_PACKAGE_DIR/tests/testdata/array/file1.toml" \
1515
"key0${n}"
1616
assert [ "${#REPLIES[@]}" -eq 0 ]
1717
done
@@ -21,7 +21,7 @@ load './util/init.sh'
2121
@test "Quick array get 2" {
2222
for m in {1..2}; do
2323
for n in {1..7}; do
24-
toml.quick_array_get "$BASALT_PACKAGE_DIR/tests/testdata/array/file1.toml" \
24+
btoml.quick_array_get "$BASALT_PACKAGE_DIR/tests/testdata/array/file1.toml" \
2525
"key${m}${n}"
2626
assert [ "${#REPLIES[@]}" -eq 1 ]
2727
assert [ -z "${REPLIES[0]}" ]
@@ -32,7 +32,7 @@ load './util/init.sh'
3232
@test "Quick array get 3" {
3333
for m in {3..10}; do
3434
for n in {1..7}; do
35-
toml.quick_array_get "$BASALT_PACKAGE_DIR/tests/testdata/array/file1.toml" \
35+
btoml.quick_array_get "$BASALT_PACKAGE_DIR/tests/testdata/array/file1.toml" \
3636
"key${m}${n}"
3737
assert [ "${#REPLIES[@]}" -eq 2 ]
3838
assert [ "${REPLIES[0]}" = 'a' ]
@@ -43,7 +43,7 @@ load './util/init.sh'
4343

4444
@test "Quick array get multiline" {
4545
for n in {0..1}; do
46-
toml.quick_array_get "$BASALT_PACKAGE_DIR/tests/testdata/array/file2.toml" \
46+
btoml.quick_array_get "$BASALT_PACKAGE_DIR/tests/testdata/array/file2.toml" \
4747
"key${n}"
4848
assert [ "${#REPLIES[@]}" -eq 1 ]
4949
assert [ "${REPLIES[0]}" = 'multiline' ]

tests/quick-string.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ load './util/init.sh'
55
@test "quick string get" {
66
for tens in {0..1}; do
77
for ones in {1..7}; do
8-
toml.quick_string_get "$BASALT_PACKAGE_DIR/tests/testdata/string/file1.toml" \
8+
btoml.quick_string_get "$BASALT_PACKAGE_DIR/tests/testdata/string/file1.toml" \
99
"key${tens}${ones}"
1010
assert [ "$REPLY" = "value${ones}" ]
1111
done

tests/util/test_util.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# shellcheck shell=bash
22

3-
test_util.toml.has_key() {
3+
test_util.btoml.has_key() {
44
if test_util.object_has_key 'TOML' "$1"; then
55
return 0
66
else
77
return 1
88
fi
99
}
1010

11-
test_util.toml.key_has_value() {
11+
test_util.btoml.key_has_value() {
1212
if test_util.object_has_key_and_value 'TOML' "$1" "$2"; then
1313
return 0
1414
else

0 commit comments

Comments
 (0)