python_skeleton/deploy_new_python_project.sh
2021-01-13 17:17:31 +02:00

58 lines
No EOL
1.3 KiB
Bash

#!/bin/bash
# shellcheck disable=SC1090
if [ -e defaults ]
then
. "$(dirname "${0}")/defaults"
fi
while [ $# -gt 0 ]
do
case "$1" in
"--author")
shift
AUTHOR="${1}"
shift
;;
"--authoring-date")
shift
AUTHORING_DATE="${1}"
shift
;;
"--project-name")
shift
PROJECT_NAME="${1}"
;;
"--project-codename")
shift
PROJECT_CODENAME="${1}"
shift
;;
"--version")
shift
VERSION="${1}"
shift
;;
"--deployment-path")
shift
DEPLOYMENT_PATH="${1}"
shift
;;
*)
echo "Ignoring unknwon parameter '${1}'"
shift
;;
esac
done
destination_path="${DEPLOYMENT_PATH}/${PROJECT_CODENAME}"
mkdir "${destination_path}"
script_path=$(dirname "${0}")
cp "${script_path}/skeleton" "${destination_path}" -rfp
mv "${destination_path}/project_codename.py" "${destination_path}/${PROJECT_CODENAME}.py"
while read -r file
do
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}"
done <<< "$(ls "${destination_path}/")"