mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-11-28 11:23:03 +01:00
* refactor(laravel): consolidate versioned plugins * fix(laravel): scope legacy aliases and defer command discovery
51 lines
1.3 KiB
Plaintext
51 lines
1.3 KiB
Plaintext
#compdef artisan
|
|
|
|
# Laravel autocompletion
|
|
# Author: John Hamelink <john@johnhamelink.com>
|
|
#
|
|
# This plugin does the following:
|
|
# - Adds aliases and autocompletion for artisan
|
|
# - Adds aliases and autocompletion for bob
|
|
|
|
local curcontext="$curcontext" state line _opts _bundles ret=1
|
|
local php_command command_list
|
|
local -a artisan_commands
|
|
|
|
_arguments -C \
|
|
'1: :->cmds' \
|
|
'*:: :->args' && ret=0
|
|
|
|
case $state in
|
|
cmds)
|
|
|
|
# Boot the application only to discover command names, not file arguments.
|
|
# Laravel 3 falls back to the static command names below.
|
|
zstyle -s ':omz:plugins:laravel' php php_command || php_command=php
|
|
if [[ -f artisan ]] && command_list=$(
|
|
"${(@Q)${(z)php_command}}" artisan list --raw --no-ansi 2>/dev/null
|
|
); then
|
|
artisan_commands=("${(@f)command_list}")
|
|
artisan_commands=(${artisan_commands[@]%%[[:space:]]*})
|
|
fi
|
|
|
|
if (( ${#artisan_commands} )); then
|
|
compadd -- "${artisan_commands[@]}"
|
|
return $?
|
|
fi
|
|
|
|
_values "Artisan command" \
|
|
'session\:install[Create a session table]' \
|
|
'migrate[Manage Migrations]' \
|
|
'test[Run a test]' \
|
|
'route\:\:call[Call a route in the CLI]' \
|
|
'key\:\:generate[Generate a key]'
|
|
ret=0
|
|
;;
|
|
args)
|
|
_files
|
|
return $?
|
|
;;
|
|
esac
|
|
|
|
return ret
|