Last active
December 14, 2015 05:49
-
-
Save tong/5038093 to your computer and use it in GitHub Desktop.
Haxe shell completion script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!bash | |
# | |
# Haxe bash completion | |
# | |
__haxe_commands() { | |
echo "-cp -js -swf -as3 -neko -php -cpp -cs -java -python -xml -main -lib -D -v -debug -dce -swf-version -swf-header -swf-lib -swf-lib-extern -java-lib -net-lib -net-std -c-arg -x -resource -prompt -cmd --flash-strict --no-traces --gen-hx-classes --next --each --display --no-output --times --no-inline --no-opt --php-front --php-lib --php-prefix --remap --interp --macro --eval --wait --connect --cwd -version --help-defines --help-metas -help --help" | |
} | |
_haxe_complete() { | |
#local cmd="${1##*/}" | |
#local line=${COMP_LINE} | |
local cur=${COMP_WORDS[COMP_CWORD]} | |
local prev=${COMP_WORDS[COMP_CWORD-1]} | |
COMPREPLY=() | |
if [[ ${cur} == -* ]] ; then | |
case $prev in | |
-debug|-help|--help|-prompt|-swf-header|-version|-v|--connect|--display|--gen-hx-classes|--help|--help-defines|--help-metas|--flash-strict|--interp|--macro|--eval|--next|--no-inline|--no-opt|--no-output|--no-traces|--times|--wait) | |
COMPREPLY=() | |
;; | |
-main) | |
COMPREPLY=() | |
;; | |
-lib) | |
if [ -d $HAXELIB ]; then | |
COMPREPLY=($(compgen -W "$(ls $HAXELIB)" -- $cur)) | |
fi | |
#return 0 | |
;; | |
-cp) | |
COMPREPLY=($(compgen -f -W -- "${cur}")) | |
;; | |
-dce) | |
COMPREPLY=($(compgen -W "full out std" -- $cur)) | |
;; | |
# -resource) | |
# COMPREPLY=($(compgen -W "<file>[@name]" -- ${cur})) | |
# return 0 | |
# ;; | |
*) | |
COMPREPLY=($(compgen -f -W "$(__haxe_commands)" -- "$cur")) | |
;; | |
esac | |
fi | |
} | |
complete -o nospace -f -F _haxe_complete haxe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment