From 58fcd79f9a5471d1ccf3c7ee80bec460cf6f0c90 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 12 Nov 2021 11:20:28 +0100 Subject: [PATCH] modmange: search sub-c,d implemented --- Pmodules/modmanage.bash.in | 85 ++++++++++++++++++++++++++++++++------ 1 file changed, 73 insertions(+), 12 deletions(-) diff --git a/Pmodules/modmanage.bash.in b/Pmodules/modmanage.bash.in index 4afced5..7748c11 100755 --- a/Pmodules/modmanage.bash.in +++ b/Pmodules/modmanage.bash.in @@ -61,6 +61,7 @@ SWITCHES: SUBCOMMANDS: + init [switches] TARGET_DIR + install [switches] module... + + search [switches] [string|pattern]... + help [subcommand] ' @@ -610,20 +611,80 @@ subcommand_install() { std::info "\nDone!\n" } # subcommand_install -############################################################################### +############################################################################## # -# delete specified module(s) -# -subcommand_delete() { - : -} +# sub-command 'search' +# +Subcommands[search]='search' +Options[search]='-o \?h -l with: -l help -l all-dep -l wrap -l glob -l src:' +Help[install]=' +USAGE: + modmanage search [switches] ... + search modules -############################################################################### -# -# remove modules which have been removed in our source -# -subcommand_cleanup() { - : +SWITCHES: + --src + Search modules in environment . + Default is the source defined in modmanage.conf. + + --with + Search module(s) in this sub-group. + + + Search modules matching given string. + + + Search modules matching given shell glob-pattern. +' + +subcommand_search() { + local -a args=() + while (($# > 0)); do + case $1 in + -h | -H | -\? | --help | -help ) + print_help "${subcommand}" + ;; + --src | --src=*) + if [[ $1 == --src ]]; then + src_root="$2" + shift + else + src_root="${1#--*=}" + fi + ;; + --with | --with=* ) + if [[ "$1" == --with ]]; then + args+=( '--with' "$2" ) + shift + else + args+=( "$1" ) + fi + ;; + --all-deps | --glob | --wrap ) + args+=( "$1" ) + ;; + -- ) + : + ;; + * ) + args+=( "$1" ) + ;; + esac + shift + done + if [[ -z ${src_root} ]]; then + local conf_file="${PMODULES_ROOT}/${PMODULES_CONFIG_DIR}/modmanage.conf" + if [[ -r ${conf_file} ]]; then + source "${conf_file}" + src_root="${SourceRoot}" + fi + fi + [[ -n ${src_root} ]] \ + || std::die 3 "Oops: no installation source given." + [[ -d ${src_root} ]] \ + || std::die 3 "Oops: '${src_root}' is not a valid installation source." + ${modulecmd} bash search --src="${src_root}" --all-release-stages \ + "${args[@]}" 2>&1 1>/dev/null } declare force='no'