From c84237c384c7fa4e615e089b7873446940fa4f09 Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Tue, 14 Jun 2022 09:52:01 +0300 Subject: [PATCH] Update readme and add more defaults --- README.md | 20 ++++++++++++++++++++ defaults | 5 +++-- deploy_new_python_project.sh | 12 ++++++------ 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 43a176a..f6abed9 100644 --- a/README.md +++ b/README.md @@ -1 +1,21 @@ # Python skeleton + +## Usage +Run: +deploy_new_python_project.sh --project-name "My Project" --project-codename my_project --deployment-path /path/to/my/repos/ +This will create the folder /path/to/my/repos/my_project with the skeleton inside and the text replaced for each option passed to the script. Check deploy_new_python_project.sh --help to see more options. + +deploy_new_python_project [--help|-h|-?] [--author|-a 'Author name'] [--authoring-date|-d 'date of creation'] [--project-name|-n 'Name of the project'] [--project-codename|-p short_project_name] [--version|-v 'version number'] [--deployment-path|-r 'path/to/copy/skeleton'] [--author-email|-e 'email@example.org'] [--url|-u 'https://domain.com'] [--license|-l 'LICENSEv1'] + + --help Show this help. + --author Author name, between quotes for spaces. + --authoring-date Date when the script was created. + --project-name Long name of the project. + --project-codename Short name without spaces for command line script. + --version Initial version 0.0.1? + --deployment-path Path to deploy the skeleton. + --author-email Email address of the author. + --url URL of the project. + --license License name. + --license-url License URL to fetch in plain text and save in your project folder. + --description Description. diff --git a/defaults b/defaults index 49aa8a5..3f38707 100644 --- a/defaults +++ b/defaults @@ -5,8 +5,9 @@ export AUTHORING_DATE=$(date +%Y) export PROJECT_NAME="Project Name" export PROJECT_CODENAME="project-codename" export VERSION=0.0.1 -export DEPLOYMENT_PATH="${HOME}/repos/" +export DEPLOYMENT_PATH="${HOME}/src/" export DESCRIPTION="" export AUTHOR_EMAIL="" export URL="" -export LICENSE="GPLv3" \ No newline at end of file +export LICENSE="GPLv3" +export LICENSE_URL="https://www.gnu.org/licenses/gpl-3.0.txt" \ No newline at end of file diff --git a/deploy_new_python_project.sh b/deploy_new_python_project.sh index e9944f1..171bd45 100755 --- a/deploy_new_python_project.sh +++ b/deploy_new_python_project.sh @@ -24,7 +24,7 @@ function usage() { # shellcheck disable=SC1090 if [ -e "$(dirname "${0}")/defaults" ] then - . "$(dirname "${0}")/defaults" + source "$(dirname "${0}")/defaults" fi while [ $# -gt 0 ] do @@ -80,7 +80,7 @@ do ;; "--license-url"|"-U") shift - license_url="${1}" + LICENSE_URL="${1}" shift ;; "--description") @@ -102,13 +102,13 @@ destination_path="${DEPLOYMENT_PATH}/${PROJECT_CODENAME}" mkdir -p "${DEPLOYMENT_PATH}" script_path=$(dirname "${0}") cp "${script_path}/skeleton" "${destination_path}" -rfp -if [ -z "${license_url}" ]; then +if [ -z "${LICENSE_URL}" ]; then case "${license}" in "GPLv3") - license_url="https://www.gnu.org/licenses/gpl-3.0.txt" + LICENSE_URL="https://www.gnu.org/licenses/gpl-3.0.txt" ;; "GPLv2") - license_url="https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt" + LICENSE_URL="https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt" ;; "GPLv1"|"GPL") licence_url="https://www.gnu.org/licenses/old-licenses/gpl-1.0.txt" @@ -119,7 +119,7 @@ if [ -z "${license_url}" ]; then esac fi if [ -n "${licence_url}" ]; then - curl -s "${license_url}" > "${destination_path}/LICENSE" + curl -s "${LICENSE_URL}" > "${destination_path}/LICENSE" fi mv "${destination_path}/project_codename" "${destination_path}/${PROJECT_CODENAME}" mv "${destination_path}/${PROJECT_CODENAME}/project_codename.py" "${destination_path}/${PROJECT_CODENAME}/${PROJECT_CODENAME}.py"