Created
December 23, 2020 02:18
-
-
Save stupoid/7015ef3b5b7d3829d775e83a8be7baac to your computer and use it in GitHub Desktop.
General shell scripts for python dev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
lint() { | |
TARGET_FOLDERS=$@ | |
if [ -z "$TARGET_FOLDERS" ]; then | |
TARGET_FOLDERS="app tests" | |
fi | |
echo "linting folders $TARGET_FOLDERS..." | |
echo "running autoflake" | |
autoflake --recursive --in-place --remove-unused-variables $TARGET_FOLDERS | |
echo "running isort" | |
isort $TARGET_FOLDERS | |
echo "running black" | |
black --quiet $TARGET_FOLDERS | |
echo "linting done" | |
} | |
watch_tests() { | |
TARGET_FOLDERS=$@ | |
if [ -z "$TARGET_FOLDERS" ]; then | |
TARGET_FOLDERS="*/*.py" | |
fi | |
echo "watching files $TARGET_FOLDERS" | |
ls $TARGET_FOLDERS | entr pytest --tb=short | |
} | |
case $1 in | |
lint) | |
shift | |
lint $@ | |
break | |
;; | |
watch-tests) | |
shift | |
watch_tests $@ | |
break | |
;; | |
*) | |
echo "Sorry, I don't understand" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment