]> gitweb.fluxo.info Git - templater.git/commitdiff
Ask for basic git config and commit the initial repository
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 28 Oct 2017 12:27:04 +0000 (10:27 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 28 Oct 2017 12:27:04 +0000 (10:27 -0200)
TODO.md
templater

diff --git a/TODO.md b/TODO.md
index a75617f4874697c4a8a96cadd07a928f1c6b8157..f05ba319a772beca3c3cdaf789cc9b6b1cb8c86b 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -21,7 +21,7 @@ TODO
   * Hugo: tell the user about adding a theme: http://gohugo.io/getting-started/quick-start/
   * Be verbose about the need to review and edit files, adding LICENSE headers into source files, etc
   * Try an alternative command-line format, like "module:option1=value,option2=value with spaces"
-  * Git: optionally configure user.name, user.email, user.signingkey, commit.gpgsign, etc
+  * Git: optionally configure user.signingkey, commit.gpgsign, etc
   * Dectect if it's locally or system installed (BASEDIR)
   * Print module descriptions along with usage
   * Split into module folders/files
index 377295a458ad3f9b5b8d7b000f50004fdd6b8996..d3f5d436d9db3058e3765cb6439d438d35289c31 100755 (executable)
--- a/templater
+++ b/templater
@@ -70,6 +70,26 @@ function __templater_copy_or_append {
   fi
 }
 
+# Read a parameter from user
+function __templater_user_input {
+  local input
+  local param="$1"
+  local default="$2"
+  shift 2
+
+  if echo $param | grep -q 'passwd'; then
+    read -s -rep "$* (defaults to $default): " input
+  else
+    read -rep "$* (defaults to $default): " input
+  fi
+
+  if [ -z "$input" ]; then
+    export $param="$default"
+  else
+    export $param="$input"
+  fi
+}
+
 # Basic implementation
 function templater_basic {
   if [ ! -e "README.md" ]; then
@@ -95,9 +115,14 @@ function templater_git {
     __templater_echo "Setting up git..."
     touch .gitignore
 
+    __templater_user_input GIT_USER  User             "-> Choose a git user name"
+    __templater_user_input GIT_EMAIL user@example.org "-> Choose a git email address"
+
     git init
+    git config user.name  $GIT_USER
+    git config user.email $GIT_EMAIL
     git add .
-    #git commit -m "Initial import"
+    git commit -m "Initial import"
   else
     __templater_echo "Git already set"
   fi