From f5dfb30fcb541e748d020de74fc2710f6d13ca49 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Tue, 19 Jan 2021 21:22:23 +0100 Subject: [PATCH] Add {avail,list}_{terse_,}output configurations --- Makefile | 4 +++ Makefile.inc.in | 6 ++++ configure | 85 ++++++++++++++++++++++++++++++++++++++++++++---- modulecmd.tcl.in | 4 +++ site.exp.in | 5 +++ 5 files changed, 98 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index e4ba56e0..efb6481f 100644 --- a/Makefile +++ b/Makefile @@ -300,6 +300,10 @@ sed -e 's|@prefix@|$(prefix)|g' \ -e 's|@nearlyforbiddendays@|$(nearlyforbiddendays)|g' \ -e 's|@tagabbrev@|$(tagabbrev)|g' \ -e 's|@tagcolorname@|$(tagcolorname)|g' \ + -e 's|@availoutput@|$(availoutput)|g' \ + -e 's|@availterseoutput@|$(availterseoutput)|g' \ + -e 's|@listoutput@|$(listoutput)|g' \ + -e 's|@listterseoutput@|$(listterseoutput)|g' \ -e 's|@autohandling@|$(setautohandling)|g' \ -e 's|@implicitrequirement@|$(setimplicitrequirement)|g' \ -e 's|@availindepth@|$(setavailindepth)|g' \ diff --git a/Makefile.inc.in b/Makefile.inc.in index 117e427a..01428437 100644 --- a/Makefile.inc.in +++ b/Makefile.inc.in @@ -129,6 +129,12 @@ tagcolorname := @tagcolorname@ # check version on magic cookie mcookieversioncheck := @mcookieversioncheck@ +# output configuration +availoutput := @availoutput@ +availterseoutput := @availterseoutput@ +listoutput := @listoutput@ +listterseoutput := @listterseoutput@ + # command location TCLSH := @TCLSH@ PYTHON := @PYTHON@ diff --git a/configure b/configure index 5a6ec462..f56962b3 100755 --- a/configure +++ b/configure @@ -38,7 +38,8 @@ availindepth implicitdefault extendeddefault moduleshome initconfin pager \ pageropts verbosity color darkbgcolors lightbgcolors termbg lockedconfigs \ icase unloadmatchorder searchmatch modulepath loadedmodules quarantinevars \ wa277 advversspec ml windowssupport nearlyforbiddendays implicitrequirement \ -tagabbrev tagcolorname mcookieversioncheck" +tagabbrev tagcolorname mcookieversioncheck availoutput availterseoutput \ +listoutput listterseoutput" compatarglist= libarglist= @@ -125,6 +126,10 @@ nearlyforbiddendays=14 tagabbrev='auto-loaded=aL:loaded=L:hidden=H:hidden-loaded=H:forbidden=F:nearly-forbidden=nF:sticky=S:super-sticky=sS' tagcolorname= mcookieversioncheck=y +availoutput='modulepath:alias:dirwsym:sym:tag:key' +availterseoutput='modulepath:alias:dirwsym:sym:tag' +listoutput='header:idx:sym:tag:key' +listterseoutput='header' # git branch to use to build compat version compatbranch='c-3.2' @@ -335,8 +340,30 @@ Optional Packages: applied over their name instead of over the name of the module they are attached to. Each element in TAGLIST is a tag name or abbreviation (elements in - TAGLIST are separated by \`:') - [$tagcolorname] + TAGLIST are separated by \`:') [$tagcolorname] + --with-avail-output=LIST + specify content to report on avail sub-command + regular output. elements accepted in LIST are: + \`modulepath', \`alias', \`dirwsym', \`sym', \`tag' + and \`key' (elements in LIST are separated by \`:') + [$availoutput] + --with-avail-terse-output=LIST + specify content to report on avail sub-command + terse output. elements accepted in LIST are: + \`modulepath', \`alias', \`dirwsym', \`sym', \`tag' + and \`key' (elements in LIST are separated by \`:') + [$availterseoutput] + --with-list-output=LIST + specify content to report on list sub-command + regular output. elements accepted in LIST are: + \`header', \`idx', \`sym', \`tag' and \`key' + (elements in LIST are separated by \`:') + [$listoutput] + --with-list-terse-output=LIST + specify content to report on list sub-command terse + output. elements accepted in LIST are: \`header', + \`idx', \`sym', \`tag' and \`key' (elements in LIST + are separated by \`:') [$listterseoutput] --with-modulepath=PATHLIST default modulepaths to set in default configuration file to be enabled (each path in PATHLIST should @@ -435,15 +462,17 @@ get_feature_value() { # parse optional argument to find package is set or disabled get_package_value() { typeset val="${1#*=}" + typeset valifunset="$2" + # use fallback value 'valifunset' when no specific value given if [ "${1//--with-/}" != "$1" ]; then - if [ "$val" = 'no' ]; then - echo '' + if [ "$val" = 'no' ] || [ "$val" = "$1" ]; then + echo "$valifunset" else echo "$val" fi else - echo '' + echo "$valifunset" fi } @@ -646,6 +675,50 @@ for arg in "$@"; do tagabbrev=$(get_package_value "$arg") ;; --with-tag-color-name*|--without-tag-color-name) tagcolorname=$(get_package_value "$arg") ;; + --with-avail-output*|--without-avail-output) + availoutput=$(get_package_value "$arg" "$availoutput") ; + allowedval=" modulepath alias dirwsym sym tag key " ; + ORIG_IFS=$IFS ; + IFS=: ; + for val in $availoutput; do + if [ "${allowedval// $val /}" = "$allowedval" ]; then + echo_error "Bad value '$val' set in option \`--with-avail-output', values allowed in list are:$allowedval" + fi ; + done ; + IFS=$ORIG_IFS ;; + --with-avail-terse-output*|--without-avail-terse-output) + availterseoutput=$(get_package_value "$arg" "$availterseoutput") ; + allowedval=" modulepath alias dirwsym sym tag key " ; + ORIG_IFS=$IFS ; + IFS=: ; + for val in $availterseoutput; do + if [ "${allowedval// $val /}" = "$allowedval" ]; then + echo_error "Bad value '$val' set in option \`--with-avail-terse-output', values allowed in list are:$allowedval" + fi ; + done ; + IFS=$ORIG_IFS ;; + --with-list-output*|--without-list-output) + listoutput=$(get_package_value "$arg" "$listoutput") ; + allowedval=" header idx sym tag key " ; + ORIG_IFS=$IFS ; + IFS=: ; + for val in $listoutput; do + if [ "${allowedval// $val /}" = "$allowedval" ]; then + echo_error "Bad value '$val' set in option \`--with-list-output', values allowed in list are:$allowedval" + fi ; + done ; + IFS=$ORIG_IFS ;; + --with-list-terse-output*|--without-list-terse-output) + listterseoutput=$(get_package_value "$arg" "$listterseoutput") ; + allowedval=" header idx sym tag key " ; + ORIG_IFS=$IFS ; + IFS=: ; + for val in $listterseoutput; do + if [ "${allowedval// $val /}" = "$allowedval" ]; then + echo_error "Bad value '$val' set in option \`--with-list-terse-output', values allowed in list are:$allowedval" + fi ; + done ; + IFS=$ORIG_IFS ;; --with-modulepath=*|--without-modulepath) modulepath=$(get_package_value "$arg") ;; --with-loadedmodules=*|--without-loadedmodules) diff --git a/modulecmd.tcl.in b/modulecmd.tcl.in index fff4f850..d9825583 100644 --- a/modulecmd.tcl.in +++ b/modulecmd.tcl.in @@ -68,6 +68,8 @@ array set g_config_defs [list\ avail_indepth {MODULES_AVAIL_INDEPTH @availindepth@ 0 {0 1}}\ avail_report_dir_sym {{} 1 0}\ avail_report_mfile_sym {{} 1 0}\ + avail_output {MODULES_AVAIL_OUTPUT {@availoutput@} 0}\ + avail_terse_output {MODULES_AVAIL_TERSE_OUTPUT {@availterseoutput@} 0}\ collection_pin_version {MODULES_COLLECTION_PIN_VERSION 0 0 {0 1}}\ collection_target {MODULES_COLLECTION_TARGET 0}\ color {MODULES_COLOR @color@ 0 {never auto always} {0 1 2} initConfColor}\ @@ -79,6 +81,8 @@ array set g_config_defs [list\ ignored_dirs {{} {CVS RCS SCCS .svn .git .SYNC .sos} 0}\ implicit_requirement {MODULES_IMPLICIT_REQUIREMENT @implicitrequirement@ 0\ {0 1}}\ + list_output {MODULES_LIST_OUTPUT {@listoutput@} 0}\ + list_terse_output {MODULES_LIST_TERSE_OUTPUT {@listterseoutput@} 0}\ locked_configs {{} {@lockedconfigs@} 0}\ mcookie_version_check {MODULES_MCOOKIE_VERSION_CHECK\ @mcookieversioncheck@ 0 {0 1}}\ diff --git a/site.exp.in b/site.exp.in index 095e9eda..1739f18b 100644 --- a/site.exp.in +++ b/site.exp.in @@ -86,6 +86,11 @@ set install_tagcolorname "@tagcolorname@" set install_mcookieversioncheck "@mcookieversioncheck@" +set install_availoutput "@availoutput@" +set install_availterseoutput "@availterseoutput@" +set install_listoutput "@listoutput@" +set install_listterseoutput "@listterseoutput@" + # command location set install_tclsh "@TCLSH@" set install_python "@PYTHON@"