mirror of
https://github.com/Pmodules/Pmodules.git
synced 2026-06-26 17:43:09 +02:00
Merge branch '168-modulecmd-sub-cmd-whatis-and-keyword-are-broken' into 'master'
Resolve "modulecmd: sub-cmd whatis and keyword are broken" Closes #168 See merge request Pmodules/src!144
This commit is contained in:
+85
-10
@@ -1752,7 +1752,7 @@ subcommand_search() {
|
||||
}
|
||||
|
||||
print_line_modulefile() {
|
||||
std::info "$4"
|
||||
std::info "$1 $4"
|
||||
}
|
||||
|
||||
print_line_csv() {
|
||||
@@ -2068,7 +2068,7 @@ subcommand_help() {
|
||||
# whatis
|
||||
#
|
||||
Subcommands[whatis]='whatis'
|
||||
Options[whatis]='-o \?H -l help'
|
||||
Options[whatis]='-o \?Ha -l help -l all'
|
||||
Help[whatis]='
|
||||
USAGE:
|
||||
module whatis [modulefile...]
|
||||
@@ -2078,11 +2078,41 @@ USAGE:
|
||||
'
|
||||
|
||||
subcommand_whatis() {
|
||||
if (( $# == 0 )); then
|
||||
subcommand_generic0 'whatis'
|
||||
else
|
||||
subcommand_generic1plus 'whatis' "$@"
|
||||
fi
|
||||
local options=()
|
||||
local args=()
|
||||
while (( $# > 0 )); do
|
||||
case $1 in
|
||||
-\? | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-a | --all )
|
||||
options+=( '-a' )
|
||||
;;
|
||||
-- )
|
||||
shift 1
|
||||
args+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
args+=( "$1" )
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
local mod_name=''
|
||||
local file_name=''
|
||||
while read mod_name file_name; do
|
||||
[[ -n ${file_name} ]] || continue
|
||||
local whatis=$("${modulecmd}" bash \
|
||||
whatis \
|
||||
"${file_name}" \
|
||||
2>&1 1>/dev/null)
|
||||
printf "%-25s: %s\n" "${mod_name}" "${whatis/*:}" 1>&2
|
||||
done < <(set +x; subcommand_search \
|
||||
--print-modulefiles \
|
||||
"${options[@]}" \
|
||||
"${args[@]}" 2>&1)
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
@@ -2091,7 +2121,7 @@ subcommand_whatis() {
|
||||
#
|
||||
Subcommands[apropos]='apropos'
|
||||
Subcommands[keyword]='apropos'
|
||||
Options[apropos]='-o \?H -l help'
|
||||
Options[apropos]='-o \?Ha -l help -l all'
|
||||
Help[apropos]='
|
||||
USAGE:
|
||||
module apropos string
|
||||
@@ -2101,7 +2131,52 @@ USAGE:
|
||||
'
|
||||
|
||||
subcommand_apropos() {
|
||||
subcommand_generic1 'apropos' "$@"
|
||||
local options=()
|
||||
local args=()
|
||||
while (( $# > 0 )); do
|
||||
case $1 in
|
||||
-\? | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-a | --all )
|
||||
options+=( '-a' )
|
||||
;;
|
||||
-- )
|
||||
shift 1
|
||||
args+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
args+=( "$1" )
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
if (( ${#args[@]} == 0 )); then
|
||||
std::die 3 "%s %s: %s" \
|
||||
"${CMD}" "${subcommand}" \
|
||||
"no search string specified"
|
||||
elif (( ${#args[@]} > 1 )); then
|
||||
std::die 3 "%s %s: %s" \
|
||||
"${CMD}" "${subcommand}" \
|
||||
"more then one search string specified"
|
||||
fi
|
||||
local arg="${args[0]}"
|
||||
local mod_name=''
|
||||
local file_name=''
|
||||
while read mod_name file_name; do
|
||||
[[ -n ${file_name} ]] || continue
|
||||
local whatis=$("${modulecmd}" bash \
|
||||
whatis \
|
||||
"${file_name}" \
|
||||
2>&1 1>/dev/null)
|
||||
whatis="${whatis/*:}"
|
||||
if [[ ${whatis,,} =~ ${arg,,} ]]; then
|
||||
printf "%-25s: %s\n" "${mod_name}" "${whatis/*:}" 1>&2
|
||||
fi
|
||||
done < <(set +x; subcommand_search \
|
||||
--print-modulefiles \
|
||||
"${options[@]}" 2>&1)
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
@@ -2358,7 +2433,7 @@ if (( ${#GroupDepths[@]} == 0 )); then
|
||||
fi
|
||||
|
||||
case ${subcommand} in
|
||||
load|purge|search|swap )
|
||||
load|purge|search|swap|whatis|apropos )
|
||||
declare -r tmpfile=$( ${mktemp} /tmp/Pmodules.XXXXXX ) \
|
||||
|| std::die 1 "Oops: unable to create tmp file!"
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user