分享一个日常使用的一段shell脚本( 二 )


echo "Bandit report:" >> code_report.txt
bandit -r "$appdir" >> "$__dir"/code_report.txt
}
function publish () {
assert_env
if ! command -v twine &>/dev/null ; then
echo "Unable to find the 'twine' command."
echo "Install from PyPI, using 'pip install twine'."
exit 1
fi
if ! pip show wheel &>/dev/null ; then
echo "Unable to find the 'wheel' command."
echo "Install from PyPI, using 'pip install wheel'."
exit 1
fi
clean
log "building package"
Python3 setup.py sdist bdist_wheel
log "uploading to PyPi"
python3 -m twine upload dist/*
log "cleaning..."
clean
echo "You probably want to also tag the version now:"
echo "git tag -a ${VERSION} -m 'version ${VERSION}'"
echo "git push --tags"
}
function build () {
echo "build task not implemented"
}
function tester () {
echo "not implemented"
assert_env
# pytest ...
}
function buildprod {
echo "build task not implemented"
assert_env
# this runs in parallel
format & deps & tester &
wait
echo "not implemented"
# shiv ...
}
function run {
echo "running app with uvicorn"
assert_env
uvicorn --workers 2 app.main:app --reload --reload-dir "$appdir"
}
function default {
# start
clean
}
function tasks {
echo "$0 <task> <args>"
echo "Tasks:"
compgen -A function | cat -n
}
# Help message (extracted from script headers)
usage() { grep '^#/' "$0" | cut --characters=4-; exit 0; }
REGEX='(^|W)(-h|--help)($|W)'
[[ "$*" =~ $REGEX ]] && usage || true
TIMEFORMAT="Task completed in %3lR"
time ${@:-default}
 
?

【分享一个日常使用的一段shell脚本】


推荐阅读