Skip to content

Commit e4d3c2a

Browse files
authored
Merge pull request #51 from DannyBen/feature/comments-in-config
Config stdlib: allow comments
2 parents 41a2324 + a07701f commit e4d3c2a

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

examples/config-ini/config.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
; comments are allowed
12
hello = world
23
bashly = works
34

examples/config-ini/configly

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,11 @@ configly_list_command() {
325325
# :src/list_command.sh
326326
# Using the standard library (lib/config.sh) to show the entire config file
327327
config_show
328+
329+
# Or to iterate through keys
330+
for key in $(config_keys) ; do
331+
echo "$key === $(config_get "$key")"
332+
done
328333
}
329334

330335
# :command.parse_requirements
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
# Using the standard library (lib/config.sh) to show the entire config file
22
config_show
3+
4+
# Or to iterate through keys
5+
for key in $(config_keys) ; do
6+
echo "$key === $(config_get "$key")"
7+
done

lib/bashly/templates/lib/config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ config_show() {
100100
# done
101101
#
102102
config_keys() {
103-
regex="^(.*)\s*="
103+
regex="^([a-zA-Z0-9_\-]+)\s*="
104104

105105
config_init
106106

spec/approvals/examples/config-ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ world
3535
+ ./configly get invalid_key
3636
No such key: invalid_key
3737
+ ./configly list
38+
; comments are allowed
3839
hello = world
3940
bashly = works
4041

42+
hello === world
43+
bashly === works

0 commit comments

Comments
 (0)