| 1 |
############################################################################## |
| 2 |
# Modules Revision 3.0 |
| 3 |
# Providing a flexible user environment |
| 4 |
# |
| 5 |
# File: completion.00-init/%M% |
| 6 |
# Revision: %I% |
| 7 |
# First Edition: 2026/08/10 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: Xavier Delaruelle, [email protected] |
| 11 |
# |
| 12 |
# Description: Fetch ground-truth completion data from 'module config' |
| 13 |
# Command: |
| 14 |
# Sub-Command: |
| 15 |
# |
| 16 |
# Comment: %C{ |
| 17 |
# Parse the 'module config' output into the set of every |
| 18 |
# existing configuration option name, so completion tests |
| 19 |
# can check that the 'config' sub-command's Tab-completion |
| 20 |
# proposes exactly this set -- neither less nor more. |
| 21 |
# Shell-agnostic: built once here and reused by every |
| 22 |
# shell's test file |
| 23 |
# }C% |
| 24 |
# |
| 25 |
############################################################################## |
| 26 |
|
| 27 |
if {$verbose} { |
| 28 |
send_user "\tParsing 'module config' output ...\n" |
| 29 |
} |
| 30 |
|
| 31 |
catch {exec $TCLSH $MODULECMD bash config --color=never} config_output |
| 32 |
|
| 33 |
# every existing configuration option name, as reported by 'module config' |
| 34 |
# (one per line, name in the first column, followed by its current value) |
| 35 |
set config_opts {} |
| 36 |
|
| 37 |
foreach line [split $config_output \n] { |
| 38 |
if {[regexp {^([a-z][a-z0-9_]*)\s} $line -> name]} { |
| 39 |
lappend config_opts $name |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
set config_opts [lsort -unique $config_opts] |
| 44 |
|
| 45 |
if {$verbose > 1} { |
| 46 |
send_user "\tfetched [llength $config_opts] configuration option names\n" |
| 47 |
} |
| 48 |
|
| 49 |
# vim:set tabstop=3 shiftwidth=3 expandtab autoindent: |