From cad13a767432528a072366dd431519ab4e568ac2 Mon Sep 17 00:00:00 2001 From: "A. Chavali" Date: Fri, 20 Dec 2019 20:58:51 +0000 Subject: ~gentemplate capable of handling variadic args By iterating over all arguments from index 1 .. the end of the list, we can get multiple projects generate at once. gentemplateoff also gets this benefit :) --- zshenv | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/zshenv b/zshenv index ffdc041..c4c7b0f 100644 --- a/zshenv +++ b/zshenv @@ -20,27 +20,31 @@ spu() { # Use } gentemplate() { - case $1 in - 'c') git clone https://github.com/Oreodave/CTemplate $2;; - 'cpp') git clone https://github.com/Oreodave/CPPTemplate $2;; - 'python') git clone https://github.com/Oreodave/PythonTemplate $2;; - 'node') git clone https://github.com/Oreodave/NodeTemplate $2;; - 'ard') git clone https://github.com/Oreodave/ArduinoTemplate $2;; - *) return;; - esac - rm -rf $2/.git; + for var in ${@:2}; do + case $1 in + 'c') git clone https://github.com/Oreodave/CTemplate $var;; + 'cpp') git clone https://github.com/Oreodave/CPPTemplate $var;; + 'python') git clone https://github.com/Oreodave/PythonTemplate $var;; + 'node') git clone https://github.com/Oreodave/NodeTemplate $var;; + 'ard') git clone https://github.com/Oreodave/ArduinoTemplate $var;; + *) return;; + esac + rm -rf $var/.git; + done } gentemplateoff () { + for var in ${@:2}; do case $1 in - 'c') cp -r ~/Projects/Templates/CTemplate $2;; - 'cpp') cp -r ~/Projects/Templates/CPPTemplate $2;; - 'python') cp -r ~/Projects/Templates/PythonTemplate $2;; - 'node') cp -r ~/Projects/Templates/NodeTemplate $2;; - 'ard') cp -r ~/Projects/Templates/ArduinoTemplate $2;; + 'c') cp -r ~/Projects/Templates/CTemplate $var;; + 'cpp') cp -r ~/Projects/Templates/CPPTemplate $var;; + 'python') cp -r ~/Projects/Templates/PythonTemplate $var;; + 'node') cp -r ~/Projects/Templates/NodeTemplate $var;; + 'ard') cp -r ~/Projects/Templates/ArduinoTemplate $var;; *) return;; esac - rm -rf $2/.git; + rm -rf $var/.git; + done } # Web Querying -- cgit v1.2.3-13-gbd6f