- Include completions/tpc.bash in package distribution - Create completions directory during build process - Copy bash completion file to target directory - Add bash completion script with comprehensive command options - Implement file and directory completion for various parameters - Support parameter-specific value completion for optimization levels - Add support for PHP version, C++ standard, and WASM target completion - Enable filename completion for input/output files and directoriesmaster
parent
a510530d9b
commit
496e6a4d69
2 changed files with 155 additions and 0 deletions
@ -0,0 +1,151 @@ |
|||||||
|
# Bash completion for the TypePHP compiler. |
||||||
|
# Generated by: tpc --generate-completion=bash |
||||||
|
|
||||||
|
_typephp_tpc_complete_files() |
||||||
|
{ |
||||||
|
local candidate |
||||||
|
COMPREPLY=() |
||||||
|
while IFS= read -r candidate; do |
||||||
|
if [[ -d "$candidate" || "$candidate" == *.php || "$candidate" == *.yml || "$candidate" == *.yaml || "$candidate" == *.prof ]]; then |
||||||
|
COMPREPLY+=("$candidate") |
||||||
|
fi |
||||||
|
done < <(compgen -f -- "$1") |
||||||
|
} |
||||||
|
|
||||||
|
_typephp_tpc_complete_python_files() |
||||||
|
{ |
||||||
|
local candidate |
||||||
|
COMPREPLY=() |
||||||
|
while IFS= read -r candidate; do |
||||||
|
if [[ -d "$candidate" || "$candidate" == *.py ]]; then |
||||||
|
COMPREPLY+=("$candidate") |
||||||
|
fi |
||||||
|
done < <(compgen -f -- "$1") |
||||||
|
} |
||||||
|
|
||||||
|
_typephp_tpc_complete_paths() |
||||||
|
{ |
||||||
|
local mode="$1" candidate |
||||||
|
COMPREPLY=() |
||||||
|
shift |
||||||
|
while IFS= read -r candidate; do |
||||||
|
COMPREPLY+=("$candidate") |
||||||
|
done < <(compgen "$mode" -- "$1") |
||||||
|
} |
||||||
|
|
||||||
|
_typephp_tpc() |
||||||
|
{ |
||||||
|
local current previous value candidate |
||||||
|
current="${COMP_WORDS[COMP_CWORD]}" |
||||||
|
previous="" |
||||||
|
if (( COMP_CWORD > 0 )); then |
||||||
|
previous="${COMP_WORDS[COMP_CWORD - 1]}" |
||||||
|
fi |
||||||
|
|
||||||
|
local index |
||||||
|
for ((index = 1; index < COMP_CWORD; index++)); do |
||||||
|
if [[ "${COMP_WORDS[index]}" == -- ]]; then |
||||||
|
compopt -o default |
||||||
|
return |
||||||
|
fi |
||||||
|
done |
||||||
|
|
||||||
|
case "$previous" in |
||||||
|
-O) |
||||||
|
COMPREPLY=( $(compgen -W '0 1 2 3' -- "$current") ) |
||||||
|
return |
||||||
|
;; |
||||||
|
--optimize) |
||||||
|
COMPREPLY=( $(compgen -W '0 1 2 3' -- "$current") ) |
||||||
|
return |
||||||
|
;; |
||||||
|
-m) |
||||||
|
COMPREPLY=( $(compgen -W 'bin lib ext' -- "$current") ) |
||||||
|
return |
||||||
|
;; |
||||||
|
--mode) |
||||||
|
COMPREPLY=( $(compgen -W 'bin lib ext' -- "$current") ) |
||||||
|
return |
||||||
|
;; |
||||||
|
--php-version) |
||||||
|
COMPREPLY=( $(compgen -W '8.2 8.3 8.4 8.5' -- "$current") ) |
||||||
|
return |
||||||
|
;; |
||||||
|
--cxx-std) |
||||||
|
COMPREPLY=( $(compgen -W 'c++17 c++20 c++23' -- "$current") ) |
||||||
|
return |
||||||
|
;; |
||||||
|
--sanitize) |
||||||
|
COMPREPLY=( $(compgen -W 'address undefined' -- "$current") ) |
||||||
|
return |
||||||
|
;; |
||||||
|
--build-dir|--output-dir|-I|--include-path|-L|--link-path) |
||||||
|
compopt -o filenames |
||||||
|
_typephp_tpc_complete_paths -d "$current" |
||||||
|
return |
||||||
|
;; |
||||||
|
--convert-python-to-php) |
||||||
|
compopt -o filenames |
||||||
|
_typephp_tpc_complete_python_files "$current" |
||||||
|
return |
||||||
|
;; |
||||||
|
-o|--output) |
||||||
|
compopt -o filenames |
||||||
|
_typephp_tpc_complete_paths -f "$current" |
||||||
|
return |
||||||
|
;; |
||||||
|
esac |
||||||
|
|
||||||
|
case "$current" in |
||||||
|
-O[0-3]) |
||||||
|
COMPREPLY=("$current") |
||||||
|
return |
||||||
|
;; |
||||||
|
-O*) |
||||||
|
value="${current#-O}" |
||||||
|
COMPREPLY=( $(compgen -W '0 1 2 3' -P '-O' -- "$value") ) |
||||||
|
return |
||||||
|
;; |
||||||
|
--wasm=*) |
||||||
|
value="${current#--wasm=}" |
||||||
|
COMPREPLY=( $(compgen -W 'component browser' -P '--wasm=' -- "$value") ) |
||||||
|
return |
||||||
|
;; |
||||||
|
--generate-completion=*) |
||||||
|
value="${current#--generate-completion=}" |
||||||
|
COMPREPLY=( $(compgen -W 'bash' -P '--generate-completion=' -- "$value") ) |
||||||
|
return |
||||||
|
;; |
||||||
|
--build-dir=*) |
||||||
|
value="${current#--build-dir=}" |
||||||
|
compopt -o filenames |
||||||
|
COMPREPLY=() |
||||||
|
while IFS= read -r candidate; do |
||||||
|
COMPREPLY+=("--build-dir=${candidate}") |
||||||
|
done < <(compgen -d -- "$value") |
||||||
|
return |
||||||
|
;; |
||||||
|
--output-dir=*) |
||||||
|
value="${current#--output-dir=}" |
||||||
|
compopt -o filenames |
||||||
|
COMPREPLY=() |
||||||
|
while IFS= read -r candidate; do |
||||||
|
COMPREPLY+=("--output-dir=${candidate}") |
||||||
|
done < <(compgen -d -- "$value") |
||||||
|
return |
||||||
|
;; |
||||||
|
-* ) |
||||||
|
COMPREPLY=( $(compgen -W '-O --optimize -o --output -h --help -v --version --profile --no-literal-strings --php-version -f --force -m --mode -r --run --debug -j --job --no-console --sanitize --cxx-std --march --target-platform --no-color --build-dir --dry -I --include-path -D --define --no-progress --lto --format -l --link-lib -L --link-path --wasm --wasm= --gen-python-helper --convert-python-to-php --output-dir --output-dir= --build-dir= --generate-completion=' -- "$current") ) |
||||||
|
return |
||||||
|
;; |
||||||
|
esac |
||||||
|
|
||||||
|
compopt -o filenames |
||||||
|
_typephp_tpc_complete_files "$current" |
||||||
|
} |
||||||
|
|
||||||
|
complete -F _typephp_tpc tpc |
||||||
|
complete -F _typephp_tpc ./tpc |
||||||
|
complete -F _typephp_tpc tpc.php |
||||||
|
complete -F _typephp_tpc bin/tpc.php |
||||||
|
complete -F _typephp_tpc ./bin/tpc.php |
||||||
Loading…
Reference in new issue