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:10:29 +01:00
author="${1}"
2021-01-13 09:46:46 +01:00
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
2021-01-13 16:10:29 +01:00
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}/")"