Skip to content

Instantly share code, notes, and snippets.

@ysugimoto
Last active July 12, 2016 02:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ysugimoto/360a386ff2a326aec0d58de9ec8e43ea to your computer and use it in GitHub Desktop.
Save ysugimoto/360a386ff2a326aec0d58de9ec8e43ea to your computer and use it in GitHub Desktop.
Artisan task selector-runner ( Depend peco )
#!/bin/sh
# Artisan ( Laravel's CLI tool ) find-up, selectable runner
# @depend
# peco - https://github.com/peco/peco
PHP=`which php`
CWD=`pwd`
ARTISAN="artisan"
COMMAND=
while [ "${CWD}" != "/" ]; do
if [ -f "${CWD}/${ARTISAN}" ]; then
COMMAND="${CWD}/${ARTISAN}"
break
else
CWD=`dirname ${CWD}`
fi
done
if [ "${COMMAND}" = "" ]; then
echo "artisan command not found."
exit
fi
while :; do
TASK=`${PHP} ${COMMAND} list | tail -n +17 | peco`
DESC=`echo ${TASK} | awk '{print $2}'`
if [ "${DESC}" != "" ]; then
TASK=`echo ${TASK} | awk '{print $1}'`
echo "${PHP} ${COMMAND} ${TASK} $@"
${PHP} ${COMMAND} ${TASK} $@
break
else
echo "Select task name, not group:"
sleep 1s
fi
done
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment