New: help function

This commit is contained in:
L-Nafaryus 2021-06-01 11:54:39 +05:00
parent 7ac40272ff
commit fd110141b1
2 changed files with 50 additions and 21 deletions

50
bin/anisotropy Executable file
View File

@ -0,0 +1,50 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.."
cd ${DIR}
anisotropy-help()
{
echo "Usage:"
echo " anisotropy <command> [options]"
echo ""
echo "Commands:"
echo " clean Clean project directory via git (.gitignore)."
echo " init Activate environment and install dependencies."
echo " run Start calculations and etc."
echo " help Show help for commands."
echo ""
echo "Options:"
echo " -c, --config <path-to-file> Use custom configuration file."
}
case $1 in
clean)
git clean -fdx
;;
init)
python -m venv env
source env/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
deactivate
;;
run)
source ${OPENFOAM}
source env/bin/activate
python ${DIR}/anisotropy/anisotropy.py
deactivate
;;
help)
anisotropy-help
exit 1
;;
*)
echo "Unknown command."
anisotropy-help
exit 1
;;
esac

View File

@ -1,21 +0,0 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.."
cd ${DIR}
if [ "$1" = "clean" ]; then
git clean -fdx
elif [ "$1" = "init" ]; then
python -m venv env
source env/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
deactivate
elif [ "$1" = "run" ]; then
source ${OPENFOAM}
source env/bin/activate
python ${DIR}/anisotropy/anisotropy.py
deactivate
fi