1 # bash completion for cpm
6 # - support --envs=filename
7 # - create completion for module
8 # - create completion for environment
10 _set_opts="-generic_fusion -ngeneric_fusion -dynamics -ndynamics -descexl -ndescexl -b -nr -nc -sc"
14 sed 's/EnvironmentName:[[:space:]]*//;t;d' | tr -d '\n'
19 sed 's/\[\([[:digit:]]\)\].*/\1/;t;d' | tr -d '\n'
24 local arg cur prev words cword split
26 # Require bash completion
27 _init_completion || return
29 _get_comp_words_by_ref
31 # subcommand or project file
34 COMPREPLY=( $(compgen -W "environment project module make" -- ${cur}) )
39 COMPREPLY=( $(compgen -W "--force" -- ${cur}) )
44 # Not even a project file is selected
48 # A project file is selected
49 elif [[ "$cword" = 3 ]]
51 COMPREPLY=( $(compgen -W "create show build path root target exec set" -- ${cur}) )
52 # A project command is selected
53 elif [[ "$cword" -ge 4 ]]
57 COMPREPLY=( $(compgen -W "--force --envs" -- ${cur}) )
60 # No path command set yet
63 COMPREPLY=( $(compgen -W "add list remove move" -- ${cur}) )
65 elif [[ "$cword" -ge 5 ]]
74 COMPREPLY=( $(compgen -W "$("${words[0]}" project "${words[2]}" path list | _paths)" -- ${cur}) )
79 COMPREPLY=( $(compgen -W "$("${words[0]}" project "${words[2]}" path list | _paths)" -- ${cur}) )
80 elif [[ "$cword" = 6 ]]
82 COMPREPLY=( $(compgen -W "up down top bottom" -- ${cur}) )
89 COMPREPLY=( $(compgen -W ". .. ... .... ....." -- ${cur}) )
92 COMPREPLY=( $(compgen -W "$(_targets < "$CLEAN_HOME/etc/IDEEnvs")" -- ${cur}) )
95 COMPREPLY=( $(compgen -W "$_set_opts" -- ${cur}) )
115 } && complete -F _cpm cpm