Skip to content

Commit 427b07e

Browse files
committed
Config option value append or subtract for list option
Allow to update colon-separated list configuration option with config sub-command. If new value starts with '+' or '-', this new value is respectively appended or subtracted from existing configuration value.
1 parent add05b0 commit 427b07e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tcl/subcmd.tcl.in

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,6 +2343,24 @@ proc cmdModuleConfig {dump_state args} {
23432343
reportErrorAndExit "Configuration option '$name' does not exist"
23442344
# set configuration
23452345
} elseif {[info exists name] && ($nameunset || [info exists value])} {
2346+
# append or subtract value to existing configuration value if new value
2347+
# starts with '+' or '-' (for colon-separated list option only)
2348+
if {[info exists value] && $confkind($name) eq {l}} {
2349+
set curconfvallist [split [getConf $name] :]
2350+
switch -- [string index $value 0] {
2351+
+ {
2352+
appendNoDupToList curconfvallist {*}[split [string range\
2353+
$value 1 end] :]
2354+
set value [join $curconfvallist :]
2355+
}
2356+
- {
2357+
lassign [getDiffBetweenList $curconfvallist [split [string\
2358+
range $value 1 end] :]] curconfvallist
2359+
set value [join $curconfvallist :]
2360+
}
2361+
}
2362+
}
2363+
23462364
if {$confvar($name) eq {}} {
23472365
reportErrorAndExit "Configuration option '$name' cannot be altered"
23482366
} elseif {$conflockable($name) eq {1} && [isConfigLocked $name]} {

0 commit comments

Comments
 (0)