MinimalistGit

Project to automate creating git repos on a minimal 'git daemon' server.
Log | Files | Refs | README | LICENSE

commit 9173555cad65da0fefc06d209291dabbeaf32fc0
parent 2ac74f83bc35259470a81568ff98b0cc4568ff04
Author: Tyler Clark <tyler.clark@foxide.xyz>
Date:   Sun,  9 Feb 2025 21:47:07 -0500

Changing script to use optcodes

Diffstat:
Mscripts/NewRepo.sh | 38++++++++++++--------------------------
1 file changed, 12 insertions(+), 26 deletions(-)

diff --git a/scripts/NewRepo.sh b/scripts/NewRepo.sh @@ -2,10 +2,9 @@ # This script will automate the creation of Git repositories # The arguments available for this script are: # -# -h, --help: Prints a help screen -# -t, --template: makes this a template repository -# -n, --name: The name of the repository (will create a directory with this name) -# -p, --private: make this repository a private repository (will not appear in web interface) +# The public repo dirs will have a .git extension, +# while the private repos will not have an extension and the template repos will have a .template extension. +# If a repo is public and a template it will have .git.template. help() { @@ -16,27 +15,14 @@ help() echo "-t, --template: Makes the repository a template repository" } -while $# -gt 0; do - case $i in - -h|--help) - help - break - ;; - -n|--name) - DIRNAME=${i}.git - echo "Dir name: ${DIRNAME}" - shift - shift - ;; - -p|--private) - echo "${DIRNAME} will be a private repo" - ;; - -t|--template) - echo "${DIRNAME} will be a template repo" - ;; - *) - echo "No arguments passed" - ;; +while getopts ":hptn:" f; do + case $f in + h | *) help + break + ;; + n) echo "Dir name: ${OPTARG}.git";; + p) echo "Repo will be private";; + t) echo "Repo will be a template";; esac done - +shift `expr $OPTIND - 1`