Skip to content

Commit c3d06a6

Browse files
committed
init: update completion with stashlist output
Update stashpop, stashrm and stashshow completion definition to use stashlist output.
1 parent b2f5dbc commit c3d06a6

File tree

4 files changed

+54
-5
lines changed

4 files changed

+54
-5
lines changed

init/bash_completion.in

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ _module_savelist() {
3131
/:$/d;'
3232
}
3333

34+
_module_stashlist() {
35+
module stashlist --color=never -s -t 2>&1 | sed '
36+
/No stash collection\.$/d;
37+
/Stash collection list$/d;
38+
/:$/d;'
39+
}
40+
3441
_module_not_yet_loaded() {
3542
_module_avail "${1:-}" | sort | @SED_ERE@ "\%^(${LOADEDMODULES//:/|})$%d"
3643
}
@@ -68,6 +75,8 @@ _module() {
6875
aliases) COMPREPLY=( $(compgen -W "@comp_aliases_opts@" -- "$cur") );;
6976
list|savelist) COMPREPLY=( $(compgen -W "@comp_list_opts@" -- "$cur") );;
7077
stashlist) COMPREPLY=( $(compgen -W "@comp_stashlist_opts@" -- "$cur") );;
78+
stashpop|stashshow|stashrm)
79+
COMPREPLY=( $(compgen -W "$(_module_stashlist)" -- "$cur") );;
7180
clear) COMPREPLY=( $(compgen -W "@comp_clear_opts@" -- "$cur") );;
7281
restore|save|saveshow|saverm|is-saved)
7382
COMPREPLY=( $(compgen -W "$(_module_savelist)" -- "$cur") );;
@@ -89,7 +98,7 @@ _module() {
8998
apropos|keyword|search)
9099
COMPREPLY=( $(compgen -W "@comp_search_opts@" -- "$cur") );;
91100
config|--reset) COMPREPLY=( $(compgen -W "@comp_config_opts@" -- "$cur") );;
92-
-h|--help|-V|--version|purge|refresh|reload|sh-to-mod|source|state|reset|stash|stashclear|stashpop|stashrm|stashshow)
101+
-h|--help|-V|--version|purge|refresh|reload|sh-to-mod|source|state|reset|stash|stashclear)
93102
;;
94103
append-path|prepend-path)
95104
COMPREPLY=( $(compgen -W "@comp_path_opts@" -- "$cur") );;
@@ -128,6 +137,8 @@ if $(type -t ml >/dev/null); then
128137
aliases) COMPREPLY=( $(compgen -W "@comp_aliases_opts@" -- "$cur") );;
129138
list|savelist) COMPREPLY=( $(compgen -W "@comp_list_opts@" -- "$cur") );;
130139
stashlist) COMPREPLY=( $(compgen -W "@comp_stashlist_opts@" -- "$cur") );;
140+
stashpop|stashshow|stashrm)
141+
COMPREPLY=( $(compgen -W "$(_module_stashlist)" -- "$cur") );;
131142
clear) COMPREPLY=( $(compgen -W "@comp_clear_opts@" -- "$cur") );;
132143
restore|save|saveshow|saverm|is-saved)
133144
COMPREPLY=( $(compgen -W "$(_module_savelist)" -- "$cur") );;
@@ -149,7 +160,7 @@ if $(type -t ml >/dev/null); then
149160
apropos|keyword|search)
150161
COMPREPLY=( $(compgen -W "@comp_search_opts@" -- "$cur") );;
151162
config|--reset) COMPREPLY=( $(compgen -W "@comp_config_opts@" -- "$cur") );;
152-
-h|--help|-V|--version|purge|refresh|reload|sh-to-mod|source|state|reset|stash|stashclear|stashpop|stashrm|stashshow)
163+
-h|--help|-V|--version|purge|refresh|reload|sh-to-mod|source|state|reset|stash|stashclear)
153164
;;
154165
append-path|prepend-path)
155166
COMPREPLY=( $(compgen -W "@comp_path_opts@" -- "$cur") );;

init/fish_completion

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ function __fish_module_use_savelist --description 'Test if module command should
4545
return 1
4646
end
4747

48+
function __fish_module_use_stashlist --description 'Test if module command should have stash collections as potential completion'
49+
for i in (commandline -opc)
50+
if contains -- $i stashpop stashrm stashshow
51+
return 0
52+
end
53+
end
54+
return 1
55+
end
56+
4857
function __fish_module_use_config --description 'Test if module command should have configuration parameters as potential completion'
4958
for i in (commandline -opc)
5059
if contains -- $i config
@@ -63,6 +72,11 @@ complete -c module -n '__fish_module_use_savelist' -f -a "(module savelist --col
6372
/Named collection list\$/d; \
6473
/:\$/d; \
6574
/:ERROR:/d;')"
75+
complete -c module -n '__fish_module_use_stashlist' -f -a "(module stashlist --color=never -s -t 2>&1 | sed '\
76+
/No stash collection\.\$/d; \
77+
/Stash collection list\$/d; \
78+
/:\$/d; \
79+
/:ERROR:/d;')"
6680
complete -c module -n '__fish_module_use_config' -f -a "--dump-state --reset advanced_version_spec auto_handling avail_indepth avail_output avail_terse_output collection_pin_version collection_pin_tag collection_target color colors contact editor extended_default extra_siteconfig home icase implicit_default implicit_requirement list_output list_terse_output locked_configs mcookie_check mcookie_version_check ml nearly_forbidden_days pager protected_envvars quarantine_support rcfile redirect_output reset_target_state run_quarantine search_match set_shell_startup shells_with_ksh_fpath silent_shell_debug tag_abbrev tag_color_name tcl_linter term_background term_width unload_match_order variant_shortcut verbosity wa_277"
6781

6882
complete -f -n '__fish_module_no_subcommand' -c module -a 'help' --description 'Print this or modulefile(s) help info'

init/tcsh_completion.in

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ alias _module_savelist '\\
1414
/Named collection list$/d; \\
1515
/:$/d; '"'"
1616

17+
alias _module_stashlist '\\
18+
@TCLSH@ "@libexecdir@/modulecmd.tcl" tcsh stashlist --color=never -s -t |& sed '"'"'\\
19+
/No stash collection\.$/d; \\
20+
/Stash collection list$/d; \\
21+
/:$/d; '"'"
22+
1723
alias _module_not_yet_loaded '\\
1824
mkfifo /tmp/modules_tcsh_completion.$$.p1 /tmp/modules_tcsh_completion.$$.p2 && \\
1925
( _module_avail | sort >! /tmp/modules_tcsh_completion.$$.p1 & ); \\
@@ -86,9 +92,9 @@ complete module 'n/help/`_module_avail`/' \
8692
"n/stash/n/" \
8793
"n/stashclear/n/" \
8894
"n/stashlist/(@comp_stashlist_opts@)/" \
89-
"n/stashpop/n/" \
90-
"n/stashrm/n/" \
91-
"n/stashshow/n/" \
95+
'n/stashpop/`_module_stashlist`/' \
96+
'n/stashrm/`_module_stashlist`/' \
97+
'n/stashshow/`_module_stashlist`/' \
9298
"n/--reset/(@comp_config_opts@)/" \
9399
'n/-h/n/' \
94100
'n/--help/n/' \

init/zsh-functions/_module.in

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ _module_savelist() {
2020
/:$/d;'
2121
}
2222

23+
_module_stashlist() {
24+
module stashlist --color=never -s -t 2>&1 | sed '
25+
/No stash collection\.$/d;
26+
/Stash collection list$/d;
27+
/:$/d;'
28+
}
29+
2330
_module_not_yet_loaded() {
2431
_module_avail ${1:-} | sort | @SED_ERE@ "\%^(${LOADEDMODULES//:/|})$%d"
2532
}
@@ -48,6 +55,13 @@ _module_saved_colls() {
4855
_describe -t saved-colls 'saved collections' saved_colls && ret=0
4956
}
5057

58+
_module_stash_colls() {
59+
local -a stash_colls;
60+
stash_colls=(${$(_module_stashlist)})
61+
62+
_describe -t stash-colls 'stash collections' stash_colls && ret=0
63+
}
64+
5165
_module_notloaded_mods() {
5266
local -a not_yet_loaded_mods;
5367
local suffix=' ';
@@ -230,6 +244,10 @@ _module() {
230244
'(-t --terse)'{-t,--terse}'[Display output in terse format]' \
231245
'(-j --json)'{-j,--json}'[Display output in JSON format]' && ret=0
232246
;;
247+
(stashpop|stashshow|stashrm)
248+
_alternative 'avail-stashs:collections:{_module_stash_colls}' \
249+
&& ret=0
250+
;;
233251
(clear)
234252
_arguments \
235253
'(-f --force)'{-f,--force}'[Skip confirmation dialog]' && ret=0

0 commit comments

Comments
 (0)