mirror of
https://github.com/envmodules/modules.git
synced 2026-06-18 00:06:53 +08:00
Reword cmdModuleConfig data structure
Split details in multiple arrays for modularity.
This commit is contained in:
@@ -8998,43 +8998,28 @@ proc cmdModuleConfig {dump_state {name {}} {value {}}} {
|
||||
silent_shell_debug [list 0 1] term_background [list dark light]]
|
||||
|
||||
# define each attribute/fetched value pair
|
||||
set conflist [list\
|
||||
contact [displayConfig [getContact] $confvar(contact)]\
|
||||
auto_handling [displayConfig [getAutoHandling] $confvar(auto_handling)\
|
||||
asked_auto_handling]\
|
||||
avail_indepth [displayConfig [getAvailInDepth] $confvar(avail_indepth)]\
|
||||
avail_report_dir_sym $::flag_default_dir\
|
||||
avail_report_mfile_sym $::flag_default_mf\
|
||||
collection_pin_version [displayConfig [pinVersionInCollection]\
|
||||
$confvar(collection_pin_version)]\
|
||||
collection_target [displayConfig [get-env $confvar(collection_target)\
|
||||
<undef>] $confvar(collection_target)]\
|
||||
color [displayConfig [getColor] $confvar(color) asked_color {0 never 1\
|
||||
auto 2 always}]\
|
||||
colors [displayConfig $::g_colors_list $confvar(colors)]\
|
||||
ignored_dirs [getIgnoredDirs]\
|
||||
pager [displayConfig "$::g_pager $::g_pager_opts" $confvar(pager)]\
|
||||
run_quarantine [displayConfig [get-env $confvar(run_quarantine)\
|
||||
<undef>] $confvar(run_quarantine)]\
|
||||
silent_shell_debug [displayConfig [get-env $confvar(silent_shell_debug)\
|
||||
<undef>] $confvar(silent_shell_debug)]\
|
||||
siteconfig $::g_siteconfig\
|
||||
tcl_ext_lib $::g_tclextlib\
|
||||
term_background [displayConfig [getTermBackground]\
|
||||
$confvar(term_background)]]
|
||||
array set confval [list contact [getContact] auto_handling\
|
||||
[getAutoHandling] avail_indepth [getAvailInDepth] avail_report_dir_sym\
|
||||
$::flag_default_dir avail_report_mfile_sym $::flag_default_mf\
|
||||
collection_pin_version [pinVersionInCollection] collection_target\
|
||||
[get-env $confvar(collection_target) <undef>] color [getColor] colors\
|
||||
$::g_colors_list ignored_dirs [getIgnoredDirs] pager "$::g_pager\
|
||||
$::g_pager_opts" run_quarantine [get-env $confvar(run_quarantine)\
|
||||
<undef>] silent_shell_debug [get-env $confvar(silent_shell_debug)\
|
||||
<undef>] siteconfig $::g_siteconfig tcl_ext_lib $::g_tclextlib\
|
||||
term_background [getTermBackground]]
|
||||
|
||||
# catch any environment variable set for modulecmd run-time execution
|
||||
foreach runenvvar [array names ::env -glob MODULES_RUNENV_*] {
|
||||
set runenvconf [string tolower [string range $runenvvar 8 end]]
|
||||
lappend conflist $runenvconf [displayConfig [get-env $runenvvar]\
|
||||
$runenvvar]
|
||||
set confval($runenvconf) [get-env $runenvvar]
|
||||
# enable modification of runenv conf
|
||||
set confvar($runenvconf) $runenvvar
|
||||
}
|
||||
array set conf $conflist
|
||||
|
||||
# set configuration
|
||||
if {$name ne {}} {
|
||||
if {![info exists conf($name)]} {
|
||||
if {![info exists confval($name)]} {
|
||||
reportErrorAndExit "Configuration key '$name' does not exist"
|
||||
} elseif {![info exists confvar($name)]} {
|
||||
reportErrorAndExit "Configuration key '$name' cannot be altered"
|
||||
@@ -9050,13 +9035,23 @@ proc cmdModuleConfig {dump_state {name {}} {value {}}} {
|
||||
}
|
||||
# report configuration
|
||||
} else {
|
||||
# some configuration may be overridden from the command-line
|
||||
array set confasked [list auto_handling asked_auto_handling color\
|
||||
asked_color]
|
||||
# internal conf value may be map to a public value
|
||||
array set confvtrans [list color [list 0 never 1 auto 2 always]]
|
||||
|
||||
reportVersion
|
||||
reportSeparateNextContent
|
||||
displayTableHeader hi {Config. name} 24 {Value (set by if default\
|
||||
overridden)} 54
|
||||
|
||||
foreach var [lsort [array names conf]] {
|
||||
append displist [format {%-25s %s} $var $conf($var)] \n
|
||||
foreach var [lsort [array names confval]] {
|
||||
set valrep [displayConfig $confval($var)\
|
||||
[expr {[info exists confvar($var)] ? $confvar($var) : {}}]\
|
||||
[expr {[info exists confasked($var)] ? $confasked($var) : {}}]\
|
||||
[expr {[info exists confvtrans($var)] ? $confvtrans($var) : {}}]]
|
||||
append displist [format {%-25s %s} $var $valrep] \n
|
||||
}
|
||||
report $displist 1
|
||||
reportSeparateNextContent
|
||||
|
||||
Reference in New Issue
Block a user