diff options
| author | Danilo M. <danix@danix.xyz> | 2026-06-05 10:21:27 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-06-05 10:21:27 +0200 |
| commit | 8284ac7c6948ffcb43a43eab7ef1ec50cbb6e820 (patch) | |
| tree | 5c4da1c0500700e5eaec7a2a10878aef4444f207 /mkhint.bash-completion | |
| parent | 9f1ad23a187a493ffa812064e6641061553e6386 (diff) | |
| download | mkhintfile-8284ac7c6948ffcb43a43eab7ef1ec50cbb6e820.tar.gz mkhintfile-8284ac7c6948ffcb43a43eab7ef1ec50cbb6e820.zip | |
feat(completion): suggest current VERSION when completing -v
When -f <package> is already on the command line, -v [TAB]
reads VERSION from the existing hint file and offers it as
the only completion candidate. No hint file = no suggestion.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'mkhint.bash-completion')
| -rw-r--r-- | mkhint.bash-completion | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/mkhint.bash-completion b/mkhint.bash-completion index 29e2523..dee57e7 100644 --- a/mkhint.bash-completion +++ b/mkhint.bash-completion @@ -26,7 +26,21 @@ _mkhintfile_completions() { COMPREPLY=($(compgen -W "${words[*]}" -- "$cur")) ;; --version|-v) - # no completion, raw text + local pkg="" i + for (( i=1; i<${#COMP_WORDS[@]}-1; i++ )); do + if [[ "${COMP_WORDS[i]}" == "--hintfile" || "${COMP_WORDS[i]}" == "-f" ]]; then + pkg="${COMP_WORDS[i+1]}" + break + fi + done + if [[ -n "$pkg" ]]; then + local hint_file="$hint_dir/${pkg}.hint" + if [[ -f "$hint_file" ]]; then + local ver + ver=$(grep -m1 '^VERSION=' "$hint_file" | cut -d= -f2 | tr -d '"') + [[ -n "$ver" ]] && COMPREPLY=($(compgen -W "$ver" -- "$cur")) + fi + fi ;; *) COMPREPLY=($(compgen -W "$all_flags" -- "$cur")) |
