python_skeleton/deploy_new_python_project.sh

58 lines
1.3 KiB
Bash
Raw Normal View History

2021-01-13 09:46:46 +01:00
#!/bin/bash
2021-01-13 16:10:29 +01:00
# shellcheck disable=SC1090
if [ -e defaults ]
then
. "$(dirname "${0}")/defaults"
fi
2021-01-13 09:46:46 +01:00
while [ $# -gt 0 ]
do
case "$1" in
"--author")
shift
2021-01-13 16:17:31 +01:00
AUTHOR="${1}"
2021-01-13 09:46:46 +01:00
shift
;;
"--authoring-date")
shift
2021-01-13 16:17:31 +01:00
AUTHORING_DATE="${1}"
2021-01-13 09:46:46 +01:00
shift
;;
"--project-name")
shift
2021-01-13 16:17:31 +01:00
PROJECT_NAME="${1}"
2021-01-13 09:46:46 +01:00
;;
"--project-codename")
shift
2021-01-13 16:17:31 +01:00
PROJECT_CODENAME="${1}"
2021-01-13 09:46:46 +01:00
shift
;;
"--version")
shift
2021-01-13 16:17:31 +01:00
VERSION="${1}"
2021-01-13 09:46:46 +01:00
shift
;;
"--deployment-path")
shift
2021-01-13 16:17:31 +01:00
DEPLOYMENT_PATH="${1}"
2021-01-13 09:46:46 +01:00
shift
;;
*)
echo "Ignoring unknwon parameter '${1}'"
shift
;;
esac
2021-01-13 16:10:29 +01:00
done
2021-01-13 16:17:31 +01:00
destination_path="${DEPLOYMENT_PATH}/${PROJECT_CODENAME}"
2021-01-13 16:10:29 +01:00
mkdir "${destination_path}"
script_path=$(dirname "${0}")
cp "${script_path}/skeleton" "${destination_path}" -rfp
2021-01-13 16:17:31 +01:00
mv "${destination_path}/project_codename.py" "${destination_path}/${PROJECT_CODENAME}.py"
2021-01-13 16:10:29 +01:00
while read -r file
do
2021-01-13 16:17:31 +01:00
sed -i "s/__project_codename__/${PROJECT_CODENAME}/g" "${file}"
sed -i "s/__author__/${AUTHOR}/g" "${file}"
sed -i "s/__authoring_date__/${AUTHORING_DATE}/g" "${file}"
sed -i "s/__project_name__/${PROJECT_NAME}/g" "${file}"
sed -i "s/__version__/${VERSION}/g" "${file}"
2021-01-13 16:10:29 +01:00
done <<< "$(ls "${destination_path}/")"