Skip to content

Commit e7cff90

Browse files
committed
Allow append/subtract value with --output option
Allow to append or subtract value on avail_*output and list_*output configuration options through --output command line switch. If value associated to --output/-o switch starts with '+' or '-', this new value is respectively appended or subtracted from existing configuration value.
1 parent a66a7a2 commit e7cff90

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

tcl/init.tcl.in

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,27 @@ proc getConf {option {valifundef {}}} {
292292
# overridden value coming the command-line (already validated)
293293
##nagelfar ignore Suspicious variable
294294
if {[info exists ::asked_$option]} {
295-
set value [set ::asked_$option]
295+
set askedval [set ::asked_$option]
296+
# append or subtract value to existing configuration value if
297+
# new value starts with '+' or '-' (for colon-separated list
298+
# option only)
299+
if {$valuekind eq {l} && [string index $askedval 0] in {+ -}} {
300+
set curvaluelist [split $value :]
301+
switch -- [string index $askedval 0] {
302+
+ {
303+
##nagelfar ignore Found constant
304+
appendNoDupToList curvaluelist {*}[split [string\
305+
range $askedval 1 end] :]
306+
}
307+
- {
308+
lassign [getDiffBetweenList $curvaluelist [split\
309+
[string range $askedval 1 end] :]] curvaluelist
310+
}
311+
}
312+
set value [join $curvaluelist :]
313+
} else {
314+
set value $askedval
315+
}
296316
}
297317

298318
# convert value to its internal representation

tcl/main.tcl.in

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,11 @@ proc parseModuleCommandArgs {topcall cmd ignerr args} {
306306
}
307307
append outputconf _output
308308

309-
# check option value is coherent with current sub-command
310-
if {[isDiffBetweenList [split $asked_output :] [lindex\
311-
$::g_config_defs($outputconf) 4]]} {
309+
# check option value is coherent with current sub-command (remove
310+
# append/subtract operator at the start if any)
311+
if {[isDiffBetweenList [split [expr {[string index $asked_output 0]\
312+
in {+ -} ? [string range $asked_output 1 end] : $asked_output}]\
313+
:] [lindex $::g_config_defs($outputconf) 4]]} {
312314
if {!$ignerr} {
313315
knerror "Invalid element in value list for '$output_arg'\
314316
option on $cmd sub-command\nAllowed elements are: [lindex\

0 commit comments

Comments
 (0)