Comments (7)
Something like the following patch, introducing the indesym
element in avail_output and avail_terse_output config options, should do the job:
diff --git a/tcl/init.tcl.in b/tcl/init.tcl.in
index 0f16eb4c..032e761d 100644
--- a/tcl/init.tcl.in
+++ b/tcl/init.tcl.in
@@ -70,10 +70,10 @@ array set g_config_defs [list\
auto_handling {MODULES_AUTO_HANDLING @autohandling@ 0 b {0 1}}\
avail_indepth {MODULES_AVAIL_INDEPTH @availindepth@ 0 b {0 1}}\
avail_output {MODULES_AVAIL_OUTPUT {@availoutput@} 0 l {modulepath alias\
- dirwsym sym tag key variant variantifspec} {} {} eltlist}\
+ dirwsym indesym sym tag key variant variantifspec} {} {} eltlist}\
avail_terse_output {MODULES_AVAIL_TERSE_OUTPUT {@availterseoutput@} 0 l\
- {modulepath alias dirwsym sym tag key variant variantifspec} {} {}\
- eltlist}\
+ {modulepath alias dirwsym indesym sym tag key variant variantifspec} {}\
+ {} eltlist}\
cache_buffer_bytes {MODULES_CACHE_BUFFER_BYTES 32768 0 i {4096 1000000} {}\
{} intbe}\
cache_expiry_secs {MODULES_CACHE_EXPIRY_SECS 0 0 i {0 31536000} {} {}\
diff --git a/tcl/report.tcl.in b/tcl/report.tcl.in
index afa0613a..b9dc823c 100644
--- a/tcl/report.tcl.in
+++ b/tcl/report.tcl.in
@@ -1284,7 +1284,11 @@ proc reportModules {search_queries header hsgrkey hstyle show_mtime show_idx\
}
# elements to include in output
- set report_sym [isEltInReport sym]
+ if {[set report_indesym [isEltInReport indesym 0]]} {
+ set report_sym 0
+ } else {
+ set report_sym [isEltInReport sym]
+ }
set report_tag [isEltInReport tag]
set report_alias [isEltInReport alias]
# enable variant report if variantifspec configured and some variant is
@@ -1387,6 +1391,15 @@ proc reportModules {search_queries header hsgrkey hstyle show_mtime show_idx\
$himatchmap] disp dispsgr displen
}
}
+ version {
+ # report symbolic version independently from the module it is
+ # attached to. only done on regular or terse output when 'indesym'
+ # element is in relative output configuration option
+ if {$report_indesym} {
+ lassign [formatListEltToDisplay $elt sy {} {} {} 0 0 {} 0 {}\
+ {} 0 $himatchmap] disp dispsgr displen
+ }
+ }
}
if {$dispsgr ne {}} {
if {$json} {
@@ -1645,10 +1658,15 @@ proc displayElementList {header sgrkey hstyle one_per_line display_idx\
# Report an output key to help understand what the SGR used on this output
# correspond to
proc displayKey {} {
+ # specific key entry for symbolic version if reported independently
+ set typesym [list {symbolic-version}]
+ if {![isEltInReport indesym 0]} {
+ lappend typesym [sgr se (]<SGR>[sgr se )] 18
+ }
+
array set skipsgr [list hi 1 db 1 tr 1 se 1 er 1 wa 1 me 1 in 1 cm 1 va 1]
array set typesgr [list mp modulepath di [list directory <SGR>/ 10] al\
- module-alias sy [list {symbolic-version} [sgr se (]<SGR>[sgr se )] 18]\
- de [list {default-version}]]
+ module-alias sy $typesym de [list {default-version}]]
set display_list {}
set len_list {}
I would like to fix this for 5.3.1, which I plan to release by the end of june (or beginning of july). Let me know if you plan to provide pull-request for these fixes in this timeframe.
from modules.
If I load an alias (gcc in my example), is it possible to see it in module list
output?
Maybe with a special module config
call?
In the completion, should I propose -gnu/12
(the real module) or -gcc
(the alias loaded by the user) ?
from modules.
This minimal patch seems ok for aliases, thx Xavier for the tip:
--- bash_completion.in.ori 2023-06-22 14:07:25.081433304 +0200
+++ bash_completion.in 2023-06-22 14:08:43.997726272 +0200
@@ -20,7 +20,7 @@
local cur="${1:-}"
# skip avail call if word currently being completed is an option keyword
if [ -z "$cur" ] || [ "${cur:0:1}" != '-' ]; then
- module avail --color=never -s -t -S --no-indepth -o '' "$cur" 2>&1
+ module avail --color=never -s -t -S --no-indepth -o 'alias' "$cur" 2>&1
fi
}
Gonna try something not too heavy for symbols.
from modules.
This patch add bash completion for aliases and symbols:
--- bash_completion.in.ori 2023-06-22 14:07:25.081433304 +0200
+++ bash_completion.in 2023-06-22 16:26:14.382431762 +0200
@@ -20,7 +20,31 @@
local cur="${1:-}"
# skip avail call if word currently being completed is an option keyword
if [ -z "$cur" ] || [ "${cur:0:1}" != '-' ]; then
- module avail --color=never -s -t -S --no-indepth -o '' "$cur" 2>&1
+ local avail_list=$(module avail --color=never -s -t -S --no-indepth -o 'alias:sym' "$cur" 2>&1)
+ # The following code is quite tricky,
+ # but basically it's necessary for aliases and symbols completion
+ # 1. Remove "(@)" alias symbol
+ # 2. Convert "name/ver(sym1:sym2:symn)" to "name/ver name/sym1 name/sym2 ..."
+ echo "$avail_list" |
+ sed 's/(@)//g' |
+ tr ' ' '\n' |
+ while IFS= read -r line
+ do
+ if [[ "$line" =~ ")" ]]
+ then
+ prefix=$(echo "$line" | awk -F '/' '{print $1}')
+ middle=$(echo "$line" | awk -F '[/(]' '{print $2}')
+ suffix=$(echo "$line" | awk -F '[/(]' '{print $3}' | tr -d ')')
+ suffixes=$(echo "$suffix" | tr ':' '\n')
+ echo "${prefix}/${middle}"
+ for item in $suffixes
+ do
+ echo "${prefix}/${item}"
+ done
+ else
+ echo "$line"
+ fi
+ done | tr '\n' ' '; echo
fi
}
I gonna open a PR with a more clean code.
from modules.
This minimal patch seems ok for aliases, thx Xavier for the tip:
--- bash_completion.in.ori 2023-06-22 14:07:25.081433304 +0200 +++ bash_completion.in 2023-06-22 14:08:43.997726272 +0200 @@ -20,7 +20,7 @@ local cur="${1:-}" # skip avail call if word currently being completed is an option keyword if [ -z "$cur" ] || [ "${cur:0:1}" != '-' ]; then - module avail --color=never -s -t -S --no-indepth -o '' "$cur" 2>&1 + module avail --color=never -s -t -S --no-indepth -o 'alias' "$cur" 2>&1 fi }
Gonna try something not too heavy for symbols.
Good. It should also be fixed for other shells with completion script (tcsh, fish, zsh).
I would suggest to create several PRs, with one to fix alias.
from modules.
This patch add bash completion for aliases and symbols:
--- bash_completion.in.ori 2023-06-22 14:07:25.081433304 +0200 +++ bash_completion.in 2023-06-22 16:26:14.382431762 +0200 @@ -20,7 +20,31 @@ local cur="${1:-}" # skip avail call if word currently being completed is an option keyword if [ -z "$cur" ] || [ "${cur:0:1}" != '-' ]; then - module avail --color=never -s -t -S --no-indepth -o '' "$cur" 2>&1 + local avail_list=$(module avail --color=never -s -t -S --no-indepth -o 'alias:sym' "$cur" 2>&1) + # The following code is quite tricky, + # but basically it's necessary for aliases and symbols completion + # 1. Remove "(@)" alias symbol + # 2. Convert "name/ver(sym1:sym2:symn)" to "name/ver name/sym1 name/sym2 ..." + echo "$avail_list" | + sed 's/(@)//g' | + tr ' ' '\n' | + while IFS= read -r line + do + if [[ "$line" =~ ")" ]] + then + prefix=$(echo "$line" | awk -F '/' '{print $1}') + middle=$(echo "$line" | awk -F '[/(]' '{print $2}') + suffix=$(echo "$line" | awk -F '[/(]' '{print $3}' | tr -d ')') + suffixes=$(echo "$suffix" | tr ':' '\n') + echo "${prefix}/${middle}" + for item in $suffixes + do + echo "${prefix}/${item}" + done + else + echo "$line" + fi + done | tr '\n' ' '; echo fi }
I gonna open a PR with a more clean code.
Code should be adapted to only rely on shell syntax and sed
. No other external tool should be used (to avoid adding new dependencies).
The easiest solution is, I think, to introduce a new element in output configuration to report symbolic versions individually (rather along their relative modulefile). Otherwise code should be added for bash, tcsh, fish and zsh.
See reportModules
, isEltInReport
and formatListEltToDisplay
procedures in tcl/report.tcl.in
.
from modules.
Looking more in depth into the indesym
implementation, it seems other parts of the code need to be updated. I will handle this part.
from modules.
Related Issues (20)
- Skip some environment definitions on source-sh HOT 2
- Highlighting modulefiles specified by tool admin. HOT 1
- module load error does not set exit code HOT 2
- Not able to switch a sticky virtual module HOT 4
- Very bad performance due to sourcing of all modules on module add HOT 12
- Loading module in fish shell prints commands to stdout HOT 2
- Error message reported about an indirect dependency issue whereas module is correctly loaded HOT 2
- Error exit code set when one requirement fails to load however alternative requirement is loaded
- Module not found error message reported whereas an alternative requirement is loaded
- module load python error: "Tcl wasn't installed properly" HOT 3
- MODULEPATH unset with `module stash` HOT 3
- Error reported when a cache file for a greater Modules version is found
- How to category software with prefix? HOT 3
- modulefile man page is in the wrong man section HOT 1
- eval a command HOT 3
- Add options to module-hide/module-forbid to explicitly hide/forbid modules based on user/group HOT 4
- Allow path element equal to delimiter character on append/prepend-path
- Complete existing filenames when pattern starts with `/` on Tcsh completion HOT 8
- errors thrown after 'SU' command issued from user: oracle (non-sudoers). HOT 2
- cmd.cmd in the pre-built package for Windows sets MODULESHOME incorrectly in certain cases HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modules.