|
Last change
on this file since 432 was
411,
checked in by g7moreau, 6 years ago
|
- Better help command (completion) and add completion on --dataset option
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | # bash completion for project-meta |
|---|
| 2 | |
|---|
| 3 | _project-meta() { |
|---|
| 4 | local cur prev |
|---|
| 5 | |
|---|
| 6 | COMPREPLY=() |
|---|
| 7 | #_get_comp_words_by_ref cur prev |
|---|
| 8 | cur="${COMP_WORDS[COMP_CWORD]}" |
|---|
| 9 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
|---|
| 10 | |
|---|
| 11 | case $prev in |
|---|
| 12 | -d|--dataset) |
|---|
| 13 | local showlist=$(project-meta dataset-list|awk '{print $1}') |
|---|
| 14 | COMPREPLY=($(compgen -W "${showlist}" -- "$cur")) |
|---|
| 15 | return 0 |
|---|
| 16 | ;; |
|---|
| 17 | |
|---|
| 18 | help) |
|---|
| 19 | local showlist=$(project-meta help|grep '^ project-meta'|awk '{print $2}') |
|---|
| 20 | COMPREPLY=($(compgen -W "${showlist}" -- "$cur")) |
|---|
| 21 | return 0 |
|---|
| 22 | ;; |
|---|
| 23 | esac |
|---|
| 24 | |
|---|
| 25 | if [[ "$cur" == '-*' || $COMP_CWORD -gt 1 ]] |
|---|
| 26 | then |
|---|
| 27 | COMPREPLY=($(compgen -W "$(project-meta help|grep "^ project-meta ${COMP_WORDS[1]}" | sed -e 's/[\[]/\n/g;'|grep -- '^-'|cut -f 1 -d ']'|cut -f 1 -d ' '|sed -e 's/|/ /g;'|xargs echo -n)" -- "$cur")) |
|---|
| 28 | else |
|---|
| 29 | COMPREPLY=($(compgen -W "$($(which project-meta || echo /usr/bin/project-meta) help|grep '^ project-meta'|awk '{print $2}'|xargs echo -n)" -- "$cur")) |
|---|
| 30 | fi |
|---|
| 31 | |
|---|
| 32 | } && complete -F _project-meta project-meta |
|---|
Note: See
TracBrowser
for help on using the repository browser.