"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tcl/report.tcl.in" between
modules-5.1.1.tar.bz2 and modules-5.2.0.tar.bz2

About: The Environment Modules package provides for the dynamic modification of a user’s environment via modulefiles.

report.tcl.in  (modules-5.1.1.tar.bz2):report.tcl.in  (modules-5.2.0.tar.bz2)
skipping to change at line 32 skipping to change at line 32
# #
# Debug, Info, Warnings and Error message handling. # Debug, Info, Warnings and Error message handling.
# #
# save message when report is not currently initialized as we do not # save message when report is not currently initialized as we do not
# know yet if debug mode is enabled or not # know yet if debug mode is enabled or not
proc reportDebug {message {showcaller 1} {caller _undef_}} { proc reportDebug {message {showcaller 1} {caller _undef_}} {
# get caller name # get caller name
if {$caller eq {_undef_} && $showcaller} { if {$caller eq {_undef_} && $showcaller} {
if {[info level] > 1} { set caller [getCallingProcName]
set caller [lindex [info level -1] 0]
} else {
set caller {}
}
} }
lappend ::errreport_buffer [list reportDebug $message $showcaller $caller] lappend ::errreport_buffer [list reportDebug $message $showcaller $caller]
} }
# regular procedure to use once error report is initialized # regular procedure to use once error report is initialized
proc __reportDebug {message {showcaller 1} {caller _undef_}} { proc __reportDebug {message {showcaller 1} {caller _undef_}} {
# display active interp details if not the main one # display active interp details if not the main one
set prefix [currentState debug_msg_prefix] set prefix [currentState debug_msg_prefix]
if {$caller eq {_undef_} && $showcaller} {
set caller [getCallingProcName]
}
# display caller name as prefix # display caller name as prefix
if {$showcaller && $caller ne {} && ($caller ne {_undef_} || [info level]\ if {$showcaller && $caller ne {}} {
> 1)} {
if {$caller eq {_undef_}} {
set caller [lindex [info level -1] 0]
}
append prefix "$caller: " append prefix "$caller: "
} }
report [sgr db "DEBUG $prefix$message"] 0 1 report [sgr db "DEBUG $prefix$message"] 0 1
} }
# alternative procedure used when debug is disabled # alternative procedure used when debug is disabled
proc __reportDebugNop {args} {} proc __reportDebugNop {args} {}
proc reportWarning {message {recordtop 0}} { proc reportWarning {message {recordtop 0}} {
reportError $message $recordtop WARNING wa 0 reportError $message $recordtop WARNING wa 0
skipping to change at line 132 skipping to change at line 127
} }
} }
proc reportTrace {message {title TRACE}} { proc reportTrace {message {title TRACE}} {
if {[isVerbosityLevel trace]} { if {[isVerbosityLevel trace]} {
# use reportError for convenience but there is no error here # use reportError for convenience but there is no error here
reportError [sgr tr $message] 0 $title tr 0 reportError [sgr tr $message] 0 $title tr 0
} }
} }
proc reportTimer {message start_us stop_us} {
set elapsed_ms [expr {($stop_us - $start_us) / 1000.0}]
report [sgr db "TIMER [format $message $elapsed_ms]"] 0 1
}
# trace procedure execution start # trace procedure execution start
proc reportTraceExecEnter {cmdstring op} { proc reportTraceExecEnter {cmdstring op} {
set caller [expr {[info level] > 1 ? [lindex [info level -1] 0] : {}}] reportDebug $cmdstring 1 [getCallingProcName]
reportDebug $cmdstring 1 $caller }
# time procedure execution duration
proc reportTimerExecEnter {cmdstring op} {
uplevel 1 set proc_timer_start [clock microseconds]
}
proc reportTimerExecLeave {cmdstring code result op} {
reportTimer "$cmdstring (%.3f ms)" [uplevel 1 set proc_timer_start]\
[clock microseconds]
} }
# is currently active message record id at top level # is currently active message record id at top level
proc isMsgRecordIdTop {} { proc isMsgRecordIdTop {} {
return [expr {[depthState msgrecordid] eq 1}] return [expr {[depthState msgrecordid] eq 1}]
} }
# record messages on the eventual additional module evaluations that have # record messages on the eventual additional module evaluations that have
# occurred during the current evaluation # occurred during the current evaluation
proc reportModuleEval {} { proc reportModuleEval {} {
skipping to change at line 252 skipping to change at line 261
} }
# purge message list in case same evaluation is re-done afterward # purge message list in case same evaluation is re-done afterward
unset ::g_msgRecord($recid) unset ::g_msgRecord($recid)
# report header if no other specific msg to output in verbose mode or in # report header if no other specific msg to output in verbose mode or in
# normal verbosity mode if currently processing a cmd which triggers # normal verbosity mode if currently processing a cmd which triggers
# multiple module evaluations that cannot be guessed by the user (excluding # multiple module evaluations that cannot be guessed by the user (excluding
# dependency evaluations which are reported by triggering top evaluation) # dependency evaluations which are reported by triggering top evaluation)
# if hidden flag is enabled report only if verbosity >= verbose2 # if hidden flag is enabled report only if verbosity >= verbose2
} elseif {(!$hidden && ([isVerbosityLevel verbose] || ([isVerbosityLevel\ } elseif {(!$hidden && ([isVerbosityLevel verbose] || ([isVerbosityLevel\
normal] && ([ongoingCommandName restore] || [ongoingCommandName\ normal] && ([ongoingCommandName restore] || [ongoingCommandName source]\
source]) && $recid eq [topState msgrecordid]))) || ($hidden &&\ || [ongoingCommandName reset] || [ongoingCommandName stash] ||\
[isVerbosityLevel verbose2])} { [ongoingCommandName stashpop]) && $recid eq [topState msgrecordid])))\
|| ($hidden && [isVerbosityLevel verbose2])} {
report $header report $header
} }
} }
# separate next content produced if any # separate next content produced if any
proc reportSeparateNextContent {} { proc reportSeparateNextContent {} {
lappend ::errreport_buffer [list reportSeparateNextContent] lappend ::errreport_buffer [list reportSeparateNextContent]
} }
# regular procedure to use once error report is initialized # regular procedure to use once error report is initialized
skipping to change at line 609 skipping to change at line 619
(@MODULES_BUILD_DATE@)} (@MODULES_BUILD_DATE@)}
} }
# disable error reporting (non-critical report only) unless debug enabled # disable error reporting (non-critical report only) unless debug enabled
proc inhibitErrorReport {} { proc inhibitErrorReport {} {
if {![isVerbosityLevel trace]} { if {![isVerbosityLevel trace]} {
setState inhibit_errreport 1 setState inhibit_errreport 1
} }
} }
proc initProcReportTrace {type prc} {
##nagelfar ignore #7 Non static subcommand
if {[isVerbosityLevel debug] && [getState timer]} {
# time execution of procedure instead of regular debug report
trace $type execution $prc enter reportTimerExecEnter
trace $type execution $prc leave reportTimerExecLeave
} elseif {[isVerbosityLevel debug2]} {
# trace each procedure call
trace $type execution $prc enter reportTraceExecEnter
}
}
# init error report and output buffered messages # init error report and output buffered messages
proc initErrorReport {} { proc initErrorReport {} {
# ensure init is done only once # ensure init is done only once
if {![isStateDefined init_error_report]} { if {![isStateDefined init_error_report]} {
setState init_error_report 1 setState init_error_report 1
# ask for color init now as debug mode has already fire lines to render # ask for color init now as debug mode has already fire lines to render
# and we want them to be reported first (not the color init lines) # and we want them to be reported first (not the color init lines)
if {[isVerbosityLevel debug]} { if {[isVerbosityLevel debug]} {
getConf color getConf color
} }
# trigger pager start if something needs to be printed, to guaranty # trigger pager start if something needs to be printed, to guaranty
# reportDebug calls during pager start are processed in buffer mode # reportDebug calls during pager start are processed in buffer mode
if {[isVerbosityLevel debug]} { if {[isVerbosityLevel debug]} {
getState reportfd getState reportfd
} }
# replace report procedures used to buffer messages until error report # only report timing information in debug mode if timer mode is enabled
# being initialized by regular report procedures if {[isVerbosityLevel debug] && ![getState timer]} {
rename ::reportDebug {} # replace report procedures used to buffer messages until error
if {[isVerbosityLevel debug]} { # report being initialized by regular report procedures
# delete initial reportDebug proc after getState which needs it
rename ::reportDebug {}
rename ::__reportDebug ::reportDebug rename ::__reportDebug ::reportDebug
} else { } else {
rename ::reportDebug {}
# set a disabled version if debug is disabled # set a disabled version if debug is disabled
rename ::__reportDebugNop ::reportDebug rename ::__reportDebugNop ::reportDebug
} }
rename ::reportError {} rename ::reportError {}
rename ::__reportError ::reportError rename ::__reportError ::reportError
rename ::reportErrorAndExit {} rename ::reportErrorAndExit {}
rename ::__reportErrorAndExit ::reportErrorAndExit rename ::__reportErrorAndExit ::reportErrorAndExit
rename ::reportSeparateNextContent {} rename ::reportSeparateNextContent {}
rename ::__reportSeparateNextContent ::reportSeparateNextContent rename ::__reportSeparateNextContent ::reportSeparateNextContent
rename ::report {} rename ::report {}
rename ::__report ::report rename ::__report ::report
# trace each procedure call # setup traces for either debug or timer reports
if {[isVerbosityLevel debug2]} { if {[isVerbosityLevel debug] && [getState timer] || [isVerbosityLevel\
# exclude core procedure from tracing debug2]} {
set excl_prc_list [list report reportDebug reportTraceExecEnter\ # list of core procedures to exclude from tracing
set excl_prc_list [list report reportDebug reportFlush reportTimer\
reportTraceExecEnter reportTimerExecEnter reportTimerExecLeave\
initProcReportTrace isVerbosityLevel reportSeparateNextContent\
getState setState unsetState lappendState lpopState currentState\ getState setState unsetState lappendState lpopState currentState\
depthState isStateDefined isStateEqual sgr getConf setConf\ depthState isStateDefined isStateEqual sgr getConf setConf\
unsetConf lappendConf] unsetConf lappendConf getCallingProcName]
foreach prc [info procs] { foreach prc [info procs] {
if {$prc ni $excl_prc_list} { if {$prc ni $excl_prc_list} {
trace add execution $prc enter reportTraceExecEnter initProcReportTrace add $prc
} }
} }
} }
# now error report is init output every message saved in buffer; first # now error report is init output every message saved in buffer; first
# message will trigger message paging configuration and startup unless # message will trigger message paging configuration and startup unless
# already done if debug mode enabled # already done if debug mode enabled
foreach errreport $::errreport_buffer { foreach errreport $::errreport_buffer {
{*}$errreport {*}$errreport
} }
skipping to change at line 682 skipping to change at line 711
if {$action eq {report}} { if {$action eq {report}} {
foreach repcall $::g_holdReport($holdid) { foreach repcall $::g_holdReport($holdid) {
{*}$repcall {*}$repcall
} }
} }
unset ::g_holdReport($holdid) unset ::g_holdReport($holdid)
} }
} }
} }
# final message output and reportfd flush and close
proc reportFlush {} {
# report execution time if asked
if {[getState timer]} {
reportSeparateNextContent
reportTimer "Total execution took %.3f ms" $::timer_start [clock\
microseconds]
}
# finish output document if json format enabled
if {[isStateEqual report_format json]} {
# render error messages all together
if {[info exists ::g_report_erralist]} {
# ignite report first to get eventual error message from report
# initialization in order 'foreach' got all messages prior firing
report "\"errors\": \[" 1
foreach {sev msg} $::g_report_erralist {
# split message in lines
lappend dispmsglist "\n{ \"severity\": \"$sev\", \"message\": \[\
\"[join [split [charEscaped $msg \"] \n] {", "}]\" \] }"
}
report "[join $dispmsglist ,] \]"
}
# inhibit next content separator if output is ending
unsetState report_sep_next
report \}
}
# close pager if enabled
if {[isStateDefined reportfd] && ![isStateEqual reportfd stderr]} {
catch {flush [getState reportfd]}
catch {close [getState reportfd]}
}
}
# check if element passed as argument (corresponding to a kind of information) # check if element passed as argument (corresponding to a kind of information)
# should be part of output content # should be part of output content
proc isEltInReport {elt {retifnotdef 1}} { proc isEltInReport {elt {retifnotdef 1}} {
# get config name relative to current sub-command and output format # get config name relative to current sub-command and output format
set conf [currentState commandname] set conf [currentState commandname]
if {[getState report_format] ne {regular}} { if {[getState report_format] ne {regular}} {
append conf _[getState report_format] append conf _[getState report_format]
} }
append conf _output append conf _output
set arrname ::g_$conf set arrname ::g_$conf
##nagelfar vartype arrname varName
if {[info exists ::g_config_defs($conf)]} { if {[info exists ::g_config_defs($conf)]} {
# build value cache if it does not exist yet # build value cache if it does not exist yet
if {![array exists $arrname]} { if {![array exists $arrname]} {
array set $arrname {} array set $arrname {}
foreach confelt [split [getConf $conf] :] { foreach confelt [split [getConf $conf] :] {
##nagelfar ignore Suspicious variable name
set ${arrname}($confelt) 1 set ${arrname}($confelt) 1
} }
} }
# check if elt is marked to be included in output # check if elt is marked to be included in output
##nagelfar ignore Suspicious variable name
set ret [info exists ${arrname}($elt)] set ret [info exists ${arrname}($elt)]
} else { } else {
# return $retifnotdef (ok by default) in case no config option # return $retifnotdef (ok by default) in case no config option
# corresponds to the current module sub-command and output format # corresponds to the current module sub-command and output format
set ret $retifnotdef set ret $retifnotdef
} }
return $ret return $ret
} }
skipping to change at line 807 skipping to change at line 874
} }
proc getErrPrereqMsg {prelist {load 1}} { proc getErrPrereqMsg {prelist {load 1}} {
if {$load} { if {$load} {
foreach pre $prelist { foreach pre $prelist {
lappend predesiglist [getModuleDesignation spec $pre] lappend predesiglist [getModuleDesignation spec $pre]
} }
lassign [list {} missing [getHintLoFirstMsg $predesiglist]] un mis\ lassign [list {} missing [getHintLoFirstMsg $predesiglist]] un mis\
hintmsg hintmsg
} else { } else {
##nagelfar ignore Found constant
lassign [list un a [getHintUnFirstMsg $prelist]] un mis hintmsg lassign [list un a [getHintUnFirstMsg $prelist]] un mis hintmsg
} }
return "Module cannot be ${un}loaded due to $mis prereq.\n$hintmsg" return "Module cannot be ${un}loaded due to $mis prereq.\n$hintmsg"
} }
proc getErrReqLoMsg {prelist} { proc getErrReqLoMsg {prelist} {
foreach pre $prelist { foreach pre $prelist {
lappend predesiglist [getModuleDesignation spec $pre] lappend predesiglist [getModuleDesignation spec $pre]
} }
return "Load of requirement [join $predesiglist { or }] failed" return "Load of requirement [join $predesiglist { or }] failed"
skipping to change at line 911 skipping to change at line 979
} }
proc popMsgRecordId {{setmsgid 1}} { proc popMsgRecordId {{setmsgid 1}} {
lpopState evalid lpopState evalid
if {$setmsgid} { if {$setmsgid} {
lpopState msgrecordid lpopState msgrecordid
} }
} }
proc clearAllMsgRecordId {} { proc clearAllMsgRecordId {} {
if {[isStateDefined evalid]} { unsetState evalid
unsetState evalid unsetState msgrecordid
}
if {[isStateDefined msgrecordid]} {
unsetState msgrecordid
}
} }
# #
# Format output text # Format output text
# #
# format an element with its syms for display in a list # format an element with its syms for display in a list
proc formatListEltToDisplay {elt eltsgr eltsuffix sym_list symsgr show_syms\ proc formatListEltToDisplay {elt eltsgr eltsuffix sym_list symsgr show_syms\
sgrdef tag_list show_tags vr_list vrsgr show_vrs {himatchmap {}}} { sgrdef tag_list show_tags vr_list vrsgr show_vrs {himatchmap {}}} {
# fetch sgr codes from tags to apply directly on main element # fetch sgr codes from tags to apply directly on main element
skipping to change at line 1068 skipping to change at line 1132
} else { } else {
append symssgr $colonsgr append symssgr $colonsgr
} }
append symssgr [sgr $symsgr $sym] append symssgr [sgr $symsgr $sym]
} }
} else { } else {
set symssgr {} set symssgr {}
set symslen 0 set symslen 0
} }
set nbws1 [expr {40 - $displen}] set nbws1 [expr {40 - $displen}]
set nbws2 [expr {20 - $symslen + [expr {$nbws1 < 0 ? $nbws1 : 0}]}] set nbws2 [expr {$nbws1 < 0 ? 20 - $symslen + $nbws1 : 20 - $symslen}]
return [list $disp $dispsgr[string repeat { } $nbws1]$symssgr[string\ return [list $disp $dispsgr[string repeat { } $nbws1]$symssgr[string\
repeat { } $nbws2]$mtime $displen] repeat { } $nbws2]$mtime $displen]
} }
proc formatArrayValToJson {vallist} { proc formatArrayValToJson {vallist} {
return [expr {[llength $vallist] > 0 ? "\[ \"[join $vallist {", "}]\" \]"\ return [expr {[llength $vallist] > 0 ? "\[ \"[join $vallist {", "}]\" \]"\
: {[]}}] : {[]}}]
} }
proc formatObjectValToJson {objlist} { proc formatObjectValToJson {objlist} {
skipping to change at line 1090 skipping to change at line 1154
if {[info exists disp]} { if {[info exists disp]} {
append disp {, } append disp {, }
} }
append disp "\"$key\": " append disp "\"$key\": "
if {$isbool} { if {$isbool} {
append disp [expr {$val ? {true} : {false}}] append disp [expr {$val ? {true} : {false}}]
} else { } else {
append disp "\"$val\"" append disp "\"$val\""
} }
} }
##nagelfar ignore Bad expression
return [expr {[info exists disp] ? "{ $disp }" : "{}"}] return [expr {[info exists disp] ? "{ $disp }" : "{}"}]
} }
# format an element with its syms for a json display in a list # format an element with its syms for a json display in a list
proc formatListEltToJsonDisplay {elt args} { proc formatListEltToJsonDisplay {elt args} {
set disp "\"$elt\": \{ \"name\": \"$elt\"" set disp "\"$elt\": \{ \"name\": \"$elt\""
foreach {key vtype val show} $args { foreach {key vtype val show} $args {
if {!$show} { if {!$show} {
continue continue
} }
skipping to change at line 1118 skipping to change at line 1183
return $disp return $disp
} }
# Prepare a map list to translate later on a substring in its highlighted # Prepare a map list to translate later on a substring in its highlighted
# counterpart. Translate substring into all module it specifies in case of an # counterpart. Translate substring into all module it specifies in case of an
# advanced version specification. Each string obtained is right trimmed from # advanced version specification. Each string obtained is right trimmed from
# wildcard. No highlight is set for strings still containing wildcard chars # wildcard. No highlight is set for strings still containing wildcard chars
# after right trim operation. No highlist map is returned at all if highlight # after right trim operation. No highlist map is returned at all if highlight
# rendering is disabled. # rendering is disabled.
proc prepareMapToHightlightSubstr {substr} { proc prepareMapToHightlightSubstr {args} {
set maplist {} set maplist {}
if {[sgr hi {}] ne {}} { if {[sgr hi {}] ne {}} {
foreach m [getAllModulesFromVersSpec $substr] { foreach substr $args {
set m [string trimright $m {*?}] foreach m [getAllModulesFromVersSpec $substr] {
if {$m ne {} && [string first * $m] == -1 && [string first ? $m] ==\ set m [string trimright $m {*?}]
-1} { if {$m ne {} && [string first * $m] == -1 && [string first ? $m]\
lappend maplist $m [sgr hi $m] == -1} {
lappend maplist $m [sgr hi $m]
}
} }
} }
} }
return $maplist return $maplist
} }
# Format list of modules obtained from a getModules call in upper context # Format list of modules obtained from a getModules call in upper context
proc reportModules {mod header hsgrkey hstyle show_mtime show_idx\ proc reportModules {search_queries header hsgrkey hstyle show_mtime show_idx\
one_per_line theader_cols excluded_tag {mod_list_order {}}} { one_per_line theader_cols excluded_tag {mod_list_order {}}} {
# link to the result module list obtained in caller context # link to the result module list obtained in caller context
upvar mod_list mod_list upvar mod_list mod_list
# output is JSON format # output is JSON format
set json [isStateEqual report_format json] set json [isStateEqual report_format json]
# elements to include in output # elements to include in output
set report_sym [isEltInReport sym] set report_sym [isEltInReport sym]
set report_tag [isEltInReport tag] set report_tag [isEltInReport tag]
skipping to change at line 1157 skipping to change at line 1224
commandname] eq {list} && $json}]] commandname] eq {list} && $json}]]
# prepare list of tag abbreviations that can be substituted and list of # prepare list of tag abbreviations that can be substituted and list of
# tags whose name should be colored # tags whose name should be colored
getConf tag_abbrev getConf tag_abbrev
getConf tag_color_name getConf tag_color_name
# prepare results for display # prepare results for display
set alias_colored [isSgrkeyColored al] set alias_colored [isSgrkeyColored al]
set default_colored [isSgrkeyColored de] set default_colored [isSgrkeyColored de]
set himatchmap [prepareMapToHightlightSubstr $mod] set himatchmap [prepareMapToHightlightSubstr {*}$search_queries]
set clean_list {} set clean_list {}
set vr_list {} set vr_list {}
# treat elements in specified order if any # treat elements in specified order if any
##nagelfar ignore #2 Badly formed if statement
foreach elt [if {[llength $mod_list_order] == 0} {array names mod_list}\ foreach elt [if {[llength $mod_list_order] == 0} {array names mod_list}\
{set mod_list_order}] { {set mod_list_order}] {
if {$report_variant} { if {$report_variant} {
set vr_list [getVariantList $elt [expr {$json ? 4 : 1}]] set vr_list [getVariantList $elt [expr {$json ? 4 : 1}]]
} }
set sym_list [getVersAliasList $elt] set sym_list [getVersAliasList $elt]
# fetch tags but clear excluded tag # fetch tags but clear excluded tag
set tag_list [replaceFromList [getTagList $elt] $excluded_tag] set tag_list [replaceFromList [getTagList $elt] $excluded_tag]
# abbreviate tags unless for json output # abbreviate tags unless for json output
if {!$json} { if {!$json} {
skipping to change at line 1250 skipping to change at line 1318
lappend clean_list $disp lappend clean_list $disp
set sgrmap($disp) $dispsgr set sgrmap($disp) $dispsgr
set lenmap($disp) $displen set lenmap($disp) $displen
} }
} }
} }
set len_list {} set len_list {}
set max_len 0 set max_len 0
if {$json} { if {$json} {
##nagelfar ignore Found constant
upvar 0 clean_list display_list upvar 0 clean_list display_list
if {![info exists display_list]} { if {![info exists display_list]} {
set display_list {} set display_list {}
} }
} else { } else {
set display_list {} set display_list {}
# dictionary-sort results unless if output order is specified # dictionary-sort results unless if output order is specified
if {[llength $mod_list_order] == 0} { if {[llength $mod_list_order] == 0} {
set clean_list [lsort -dictionary $clean_list] set clean_list [lsort -dictionary $clean_list]
} }
skipping to change at line 1278 skipping to change at line 1347
} }
# output table header if needed and not yet done # output table header if needed and not yet done
if {[llength $display_list] > 0 && $show_mtime && ![isStateDefined\ if {[llength $display_list] > 0 && $show_mtime && ![isStateDefined\
theader_shown]} { theader_shown]} {
setState theader_shown 1 setState theader_shown 1
displayTableHeader {*}$theader_cols displayTableHeader {*}$theader_cols
} }
# output formatted elements # output formatted elements
displayElementList $header $hsgrkey $hstyle $one_per_line $show_idx\ displayElementList $header $hsgrkey $hstyle $one_per_line $show_idx 1\
$display_list $len_list $max_len $display_list $len_list $max_len
} }
proc showModulePath {} { proc showModulePath {} {
set modpathlist [getModulePathList] set modpathlist [getModulePathList]
if {[llength $modpathlist] > 0} { if {[llength $modpathlist] > 0} {
report {Search path for module files (in search order):} report {Search path for module files (in search order):}
foreach path $modpathlist { foreach path $modpathlist {
report " [sgr mp $path]" report " [sgr mp $path]"
} }
skipping to change at line 1324 skipping to change at line 1393
set lrep [tcl::mathfunc::max [expr {($tty_cols - $len - 2)/2}] 1] set lrep [tcl::mathfunc::max [expr {($tty_cols - $len - 2)/2}] 1]
set rrep [tcl::mathfunc::max [expr {$tty_cols - $len - 2 - $lrep}] 1] set rrep [tcl::mathfunc::max [expr {$tty_cols - $len - 2 - $lrep}] 1]
report "[string repeat - $lrep] [sgr $sgrkey $title] [string repeat -\ report "[string repeat - $lrep] [sgr $sgrkey $title] [string repeat -\
$rrep]" $rrep]"
} }
} }
# get a list of elements and print them in a column or in a # get a list of elements and print them in a column or in a
# one-per-line fashion # one-per-line fashion
proc displayElementList {header sgrkey hstyle one_per_line display_idx\ proc displayElementList {header sgrkey hstyle one_per_line display_idx\
display_list {len_list {}} {max_len 0}} { start_idx display_list {len_list {}} {max_len 0}} {
set elt_cnt [llength $display_list] set elt_cnt [llength $display_list]
reportDebug "header=$header, sgrkey=$sgrkey, hstyle=$hstyle,\ reportDebug "header=$header, sgrkey=$sgrkey, hstyle=$hstyle,\
elt_cnt=$elt_cnt, max_len=$max_len, one_per_line=$one_per_line,\ elt_cnt=$elt_cnt, max_len=$max_len, one_per_line=$one_per_line,\
display_idx=$display_idx" display_idx=$display_idx, start_idx=$start_idx"
# end proc if no element are to print # end proc if no element are to print
if {$elt_cnt == 0} { if {$elt_cnt == 0} {
return return
} }
# output is JSON format # output is JSON format
set json [isStateEqual report_format json] set json [isStateEqual report_format json]
# display header if any provided # display header if any provided
if {$header ne {noheader}} { if {$header ne {noheader}} {
skipping to change at line 1353 skipping to change at line 1422
} else { } else {
report [sgr $sgrkey $header]: report [sgr $sgrkey $header]:
} }
} }
if {$json} { if {$json} {
set displist [join $display_list ,\n] set displist [join $display_list ,\n]
# display one element per line # display one element per line
} elseif {$one_per_line} { } elseif {$one_per_line} {
if {$display_idx} { if {$display_idx} {
set idx 1 set idx $start_idx
foreach elt $display_list { foreach elt $display_list {
append displist [format {%2d) %s } $idx $elt] \n append displist [format {%2d) %s } $idx $elt] \n
incr idx incr idx
} }
} else { } else {
append displist [join $display_list \n] \n append displist [join $display_list \n] \n
} }
# elsewhere display elements in columns # elsewhere display elements in columns
} else { } else {
if {$display_idx} { if {$display_idx} {
skipping to change at line 1411 skipping to change at line 1480
set cur_rows [expr {int(ceil(double($elt_cnt) / $cur_cols))}] set cur_rows [expr {int(ceil(double($elt_cnt) / $cur_cols))}]
} }
for {set i 0} {$i < $cur_cols} {incr i} { for {set i 0} {$i < $cur_cols} {incr i} {
set cur_col_width($i) 0 set cur_col_width($i) 0
} }
for {set i 0} {$i < $cur_rows} {incr i} { for {set i 0} {$i < $cur_rows} {incr i} {
set row_width($i) 0 set row_width($i) 0
} }
set istart 0 set istart 0
} else { } else {
##nagelfar ignore Unknown variable
set istart [expr {$col * $cur_rows}] set istart [expr {$col * $cur_rows}]
# only remove width of elements from current col # only remove width of elements from current col
for {set row 0} {$row < ($i % $cur_rows)} {incr row} { for {set row 0} {$row < ($i % $cur_rows)} {incr row} {
##nagelfar ignore Unknown variable
incr row_width($row) -[expr {$pre_col_width + $elt_prefix_len}] incr row_width($row) -[expr {$pre_col_width + $elt_prefix_len}]
} }
} }
set restart_loop 0 set restart_loop 0
for {set i $istart} {$i < $elt_cnt} {incr i} { for {set i $istart} {$i < $elt_cnt} {incr i} {
set col [expr {int($i / $cur_rows)}] set col [expr {int($i / $cur_rows)}]
set row [expr {$i % $cur_rows}] set row [expr {$i % $cur_rows}]
# restart loop if a column width change # restart loop if a column width change
if {[lindex $elt_len $i] > $cur_col_width($col)} { if {[lindex $elt_len $i] > $cur_col_width($col)} {
set pre_col_width $cur_col_width($col) set pre_col_width $cur_col_width($col)
skipping to change at line 1468 skipping to change at line 1539
} }
reportDebug list=$display_list reportDebug list=$display_list
reportDebug "rows/cols=$rows/$cols,\ reportDebug "rows/cols=$rows/$cols,\
lastcol_item_cnt=[expr {int($elt_cnt % $rows)}]" lastcol_item_cnt=[expr {int($elt_cnt % $rows)}]"
for {set row 0} {$row < $rows} {incr row} { for {set row 0} {$row < $rows} {incr row} {
for {set col 0} {$col < $cols} {incr col} { for {set col 0} {$col < $cols} {incr col} {
set index [expr {$col * $rows + $row}] set index [expr {$col * $rows + $row}]
if {$index < $elt_cnt} { if {$index < $elt_cnt} {
if {$display_idx} { if {$display_idx} {
append displist [format "%2d) " [expr {$index +1}]] append displist [format "%2d) " [expr {$index +$start_idx}]]
} }
# cannot use 'format' as strings may contain SGR codes # cannot use 'format' as strings may contain SGR codes
append displist [lindex $display_list $index][string repeat\ append displist [lindex $display_list $index][string repeat\
{ } [expr {$col_width($col) - [lindex $len_list $index]}]] { } [expr {$col_width($col) - [lindex $len_list $index]}]]
} }
} }
append displist \n append displist \n
} }
} }
if {$json && $header ne {noheader}} { if {$json && $header ne {noheader}} {
skipping to change at line 1594 skipping to change at line 1665
foreach len $len_list { foreach len $len_list {
if {$len > $max_len} { if {$len > $max_len} {
set max_len $len set max_len $len
} }
} }
if {[llength $display_list] > 0} { if {[llength $display_list] > 0} {
# display header # display header
report Key: report Key:
# display key content # display key content
displayElementList noheader {} {} 0 0 $display_list $len_list $max_len displayElementList noheader {} {} 0 0 0 $display_list $len_list $max_len
} }
} }
# Return conf value and from where an eventual def value has been overridden # Return conf value and from where an eventual def value has been overridden
proc displayConfig {val env_var {asked 0} {trans {}} {locked 0}} { proc displayConfig {val env_var {asked 0} {trans {}} {locked 0}} {
array set transarr $trans array set transarr $trans
# get overridden value and know what has overridden it # get overridden value and know what has overridden it
if {$asked} { if {$asked} {
set defby " (cmd-line)" set defby " (cmd-line)"
skipping to change at line 1621 skipping to change at line 1692
} }
# translate fetched value if translation table exists # translate fetched value if translation table exists
if {[info exists transarr($val)]} { if {[info exists transarr($val)]} {
set val $transarr($val) set val $transarr($val)
} }
return $val$defby return $val$defby
} }
# report linter output as error/warning messages
proc displayLinterOutput {linter output} {
switch -- $linter {
nagelfar {
# parsing linter output
set report_list {}
foreach line [split $output \n] {
set firstword [string range $line 0 [string first { } $line]-1]
switch -- $firstword {
Checking - Parsing {}
Line {
# add message of previous line if any
if {[info exists msg]} {
lappend report_list $msg
}
# extract information from message line
set colidx [string first : $line]
set linenum [string trimleft [string range $line 5\
$colidx-1]]
set severity [string index $line $colidx+2]
switch -- $severity {
W {
set severity WARNING
set sgrkey wa
set raisecnt 0
}
E {
set severity ERROR
set sgrkey er
set raisecnt 1
}
default {
set severity NOTICE
set sgrkey in
set raisecnt 0
}
}
set msg [string range $line $colidx+4 end]
# start recorded message properties
lappend report_list $linenum $severity $sgrkey $raisecnt
}
default {
# this line is continuing message started previously
append msg \n[string trimleft $line]
}
}
}
# add message of last line if any
if {[info exists msg]} {
lappend report_list $msg
unset msg
}
# report messages
foreach {linenum severity sgrkey raisecnt mesg} $report_list {
reportError $mesg 0 "[format %-7s $severity] line $linenum"\
$sgrkey $raisecnt
}
}
default {
reportError $output
}
}
}
proc reportMlUsage {} { proc reportMlUsage {} {
reportVersion reportVersion
report {Usage: ml [options] [command] [args ...] report {Usage: ml [options] [command] [args ...]
ml [options] [[-]modulefile ...] ml [options] [[-]modulefile ...]
Examples: Examples:
ml equivalent to: module list ml equivalent to: module list
ml foo bar equivalent to: module load foo bar ml foo bar equivalent to: module load foo bar
ml -foo -bar baz equivalent to: module unload foo bar; module load baz ml -foo -bar baz equivalent to: module unload foo bar; module load baz
ml avail -t equivalent to: module avail -t ml avail -t equivalent to: module avail -t
See 'module --help' to get available commands and options.} See 'module --help' to get available commands and options.}
} }
proc reportUsage {} { proc reportUsage {} {
reportVersion reportVersion
##nagelfar ignore #106 Too long line
report {Usage: module [options] [command] [args ...] report {Usage: module [options] [command] [args ...]
Loading / Unloading commands: Loading / Unloading commands:
add | load modulefile [...] Load modulefile(s) add | load modulefile [...] Load modulefile(s)
try-add | try-load modfile [...] Load modfile(s), no complain if not found try-add | try-load modfile [...] Load modfile(s), no complain if not found
add-any | load-any modfile [...] Load first available modulefile in list add-any | load-any modfile [...] Load first available modulefile in list
rm | unload modulefile [...] Remove modulefile(s) rm | unload modulefile [...] Remove modulefile(s)
purge Unload all loaded modulefiles purge Unload all loaded modulefiles
reload Unload then load all loaded modulefiles reload Unload then load all loaded modulefiles
switch | swap [mod1] mod2 Unload mod1 and load mod2 switch | swap [mod1] mod2 Unload mod1 and load mod2
refresh Refresh loaded module volatile components refresh Refresh loaded module volatile components
reset Restore initial environment
Listing / Searching commands: Listing / Searching commands:
list [-a] [-t|-l|-j] [-S|-C] [mod ...] list [-a] [-t|-l|-j] [-S|-C] [mod ...]
List all or matching loaded modules List all or matching loaded modules
avail [-a] [-t|-l|-j] [-S|-C] [-d|-L] [--indepth|--no-indepth] [mod ...] avail [-a] [-t|-l|-j] [-S|-C] [-d|-L] [--indepth|--no-indepth] [mod ...]
List all or matching available modules List all or matching available modules
aliases [-a] List all module aliases aliases [-a] List all module aliases
whatis [-a] [-j] [modulefile ...] Print whatis information of modulefile(s) whatis [-a] [-j] [modulefile ...] Print whatis information of modulefile(s)
apropos | keyword | search [-a] [-j] str apropos | keyword | search [-a] [-j] str
Search all name and whatis containing str Search all name and whatis containing str
is-loaded [modulefile ...] Test if any of the modulefile(s) are loaded is-loaded [modulefile ...] Test if any of the modulefile(s) are loaded
is-avail modulefile [...] Is any of the modulefile(s) available is-avail modulefile [...] Is any of the modulefile(s) available
info-loaded modulefile Get full name of matching loaded module(s) info-loaded modulefile Get full name of matching loaded module(s)
Collection of modules handling commands: Collection of modules handling commands:
save [collection|file] Save current module list to collection save [collection|file] Save current module list to collection
restore [collection|file] Restore module list from collection or file restore [collection|file] Restore module list from collection or file
saverm [collection] Remove saved collection saverm [collection] Remove saved collection
saveshow [collection|file] Display information about collection saveshow [collection|file] Display information about collection
savelist [-t|-l|-j] List all saved collections savelist [-a] [-t|-l|-j] [-S|-C] [collection ...]
List all or matching saved collections
is-saved [collection ...] Test if any of the collection(s) exists is-saved [collection ...] Test if any of the collection(s) exists
stash Save current environment and reset
stashpop [stash] Restore then remove stash collection
stashrm [stash] Remove stash collection
stashshow [stash] Display information about stash collection
stashclear Remove all stash collections
stashlist List all stash collections
Environment direct handling commands: Environment direct handling commands:
prepend-path [-d c] var val [...] Prepend value to environment variable prepend-path [-d c] var val [...] Prepend value to environment variable
append-path [-d c] var val [...] Append value to environment variable append-path [-d c] var val [...] Append value to environment variable
remove-path [-d c] var val [...] Remove value from environment variable remove-path [-d c] var val [...] Remove value from environment variable
Other commands: Other commands:
help [modulefile ...] Print this or modulefile(s) help info help [modulefile ...] Print this or modulefile(s) help info
display | show modulefile [...] Display information about modulefile(s) display | show modulefile [...] Display information about modulefile(s)
test [modulefile ...] Test modulefile(s) test [modulefile ...] Test modulefile(s)
skipping to change at line 1690 skipping to change at line 1837
unuse dir [...] Remove dir(s) from MODULEPATH variable unuse dir [...] Remove dir(s) from MODULEPATH variable
is-used [dir ...] Is any of the dir(s) enabled in MODULEPATH is-used [dir ...] Is any of the dir(s) enabled in MODULEPATH
path modulefile Print modulefile path path modulefile Print modulefile path
paths modulefile Print path of matching available modules paths modulefile Print path of matching available modules
clear [-f] Reset Modules-specific runtime information clear [-f] Reset Modules-specific runtime information
source scriptfile [...] Execute scriptfile(s) source scriptfile [...] Execute scriptfile(s)
config [--dump-state|name [val]] Display or set Modules configuration config [--dump-state|name [val]] Display or set Modules configuration
state [name] Display Modules state state [name] Display Modules state
sh-to-mod shell shellscript [arg ...] sh-to-mod shell shellscript [arg ...]
Make modulefile from script env changes Make modulefile from script env changes
mod-to-sh shell modulefile [...]
Make shell code from modulefile env changes
edit modulefile Open modulefile in editor edit modulefile Open modulefile in editor
lint [-a] [modulefile ...] Check syntax of modulefile
Switches: Switches:
-t | --terse Display output in terse format -t | --terse Display output in terse format
-l | --long Display output in long format -l | --long Display output in long format
-j | --json Display output in JSON format -j | --json Display output in JSON format
-o LIST | --output=LIST -o LIST | --output=LIST
Define elements to output on 'avail' or 'list' sub-commands Define elements to output on 'avail' or 'list' sub-commands
in addition to module names (LIST is made of items like in addition to module names (LIST is made of items like
'sym', 'tag' or 'key' separated by ':') 'sym', 'tag' or 'key' separated by ':')
-a | --all Include hidden modules in search -a | --all Include hidden modules in search
skipping to change at line 1723 skipping to change at line 1873
or 'switch' sub-commands (LIST is made of tag names or 'switch' sub-commands (LIST is made of tag names
separated by ':') separated by ':')
Options: Options:
-h | --help This usage info -h | --help This usage info
-V | --version Module version -V | --version Module version
-D | --debug Enable debug messages -D | --debug Enable debug messages
-T | --trace Enable trace messages -T | --trace Enable trace messages
-v | --verbose Enable verbose messages -v | --verbose Enable verbose messages
-s | --silent Turn off error, warning and informational messages -s | --silent Turn off error, warning and informational messages
--timer Report execution times
--paginate Pipe mesg output into a pager if stream attached to terminal --paginate Pipe mesg output into a pager if stream attached to terminal
--no-pager Do not pipe message output into a pager --no-pager Do not pipe message output into a pager
--redirect Send output to stdout (only for sh, bash, ksh, zsh and fish) --redirect Send output to stdout (only for sh, bash, ksh, zsh and fish)
--no-redirect Send output to stderr --no-redirect Send output to stderr
--color[=WHEN] Colorize the output; WHEN can be 'always' (default if --color[=WHEN] Colorize the output; WHEN can be 'always' (default if
omitted), 'auto' or 'never' omitted), 'auto' or 'never'
-w COLS | --width=COLS -w COLS | --width=COLS
Set output width to COLS columns.} Set output width to COLS columns.}
} }
 End of changes. 42 change blocks. 
47 lines changed or deleted 198 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)