Only run external commands as necessary, also make sure we only recognize
commands in the right places (for example, 'rico planet planet ' shouldn't cause planet tab-completion).
This commit is contained in:
parent
4718f1657b
commit
ff100e6a94
|
@ -82,31 +82,31 @@ complete -F _racket $filenames racket
|
||||||
complete -F _racket $filenames gracket
|
complete -F _racket $filenames gracket
|
||||||
complete -F _racket $filenames gracket-text
|
complete -F _racket $filenames gracket-text
|
||||||
|
|
||||||
|
# Expects ${cur} as arg 1
|
||||||
|
_rico_planet()
|
||||||
|
{
|
||||||
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
local planetcmds=$( echo '' '--help' ; for x in `rico planet --help 2>&1 | sed -n -e 's/^ \(.[^ ]*\).*/\1/p'` ; do echo ${x} ; done )
|
||||||
|
COMPREPLY=( $(compgen -W "${planetcmds}" -- ${cur}) )
|
||||||
|
}
|
||||||
|
|
||||||
_rico()
|
_rico()
|
||||||
{
|
{
|
||||||
local cur prev opts base cmds makeopts tmpoutput
|
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
||||||
|
|
||||||
#
|
|
||||||
# The basic commands we'll complete.
|
|
||||||
#
|
|
||||||
#local cmds="make setup planet exe pack c-ext decompile distribute expand --help docs"
|
|
||||||
tmpoutput=`rico --help 2>&1 | sed -n -e 's/^ \(.[^ ]*\).*/\1/p'`
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
# removing the empty string on the next line breaks things. such as my brain.
|
|
||||||
cmds=$( echo '' '--help' ; for x in ${tmpoutput} ; do echo ${x} ; done )
|
|
||||||
makeopts="--disable-inline --no-deps -p --prefix --no-prim -v -vv --help -h"
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Complete the arguments to some of the basic commands.
|
# Complete the arguments to some of the basic commands.
|
||||||
#
|
#
|
||||||
|
local makeopts="--disable-inline --no-deps -p --prefix --no-prim -v -vv --help -h"
|
||||||
|
|
||||||
if [ $COMP_CWORD -eq 1 ]; then
|
if [ $COMP_CWORD -eq 1 ]; then
|
||||||
|
# removing the empty string on the next line breaks things. such as my brain.
|
||||||
|
local cmds=$( echo '' '--help' ; for x in `rico --help 2>&1 | sed -n -e 's/^ \(.[^ ]*\).*/\1/p'` ; do echo ${x} ; done )
|
||||||
COMPREPLY=($(compgen -W "${cmds}" -- ${cur}))
|
COMPREPLY=($(compgen -W "${cmds}" -- ${cur}))
|
||||||
else
|
elif [ $COMP_CWORD -eq 2 ]; then
|
||||||
|
# Here we'll handle the main rico commands
|
||||||
|
local prev="${COMP_WORDS[1]}"
|
||||||
case "${prev}" in
|
case "${prev}" in
|
||||||
make)
|
make)
|
||||||
case "${cur}" in
|
case "${cur}" in
|
||||||
|
@ -119,8 +119,7 @@ _rico()
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
planet)
|
planet)
|
||||||
planetcmds=$( echo '' '--help' ; for x in `rico planet --help 2>&1 | sed -n -e 's/^ \(.[^ ]*\).*/\1/p'` ; do echo ${x} ; done )
|
_rico_planet
|
||||||
COMPREPLY=( $(compgen -W "${planetcmds}" -- ${cur}) )
|
|
||||||
;;
|
;;
|
||||||
--help)
|
--help)
|
||||||
;;
|
;;
|
||||||
|
@ -128,6 +127,8 @@ _rico()
|
||||||
_filedir
|
_filedir
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
else
|
||||||
|
_filedir
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user