From 9633d2b8e19830fd06cc1b6cba9e5120d91a6563 Mon Sep 17 00:00:00 2001 From: Alexander Gehrke Date: Wed, 14 Sep 2022 14:09:38 +0200 Subject: [PATCH] Add g8 wrapper for local templates --- devel/g8 | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 devel/g8 diff --git a/devel/g8 b/devel/g8 new file mode 100755 index 0000000..2394d34 --- /dev/null +++ b/devel/g8 @@ -0,0 +1,42 @@ +#!/bin/zsh +source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh +G8=$(next-in-path g8 $0) + +args=() +zparseopts -D -E \ + b:=branch -branch:=branch \ + t:=tag -tag:=tag \ + d:=directory -directory:=directory \ + o:=out -out:=out \ + h:=knownhosts -known-hosts:=knownhosts \ + f=force -force=force \ + -version=version \ + -help=help + +for arg in "$@"; do + if [[ $arg =~ = ]]; then + args+=($arg) + elif [[ -n $template ]]; then + echo "Error: multiple templates specified:\n- $template\n- $arg" + exit 1 + elif [[ $arg =~ / ]]; then + template=$arg + else + for template_path in \ + ${XDG_CONFIG_HOME:-$HOME/.config}/templates/$arg \ + ${XDG_CONFIG_HOME:-$HOME/.config}/templates/$arg.g8 \ + ${XDG_DATA_HOME:-$HOME/.local/share}/templates/$arg \ + ${XDG_DATA_HOME:-$HOME/.local/share}/templates/$arg.g8 + do + if [[ -d $template_path ]]; then + template=file://$template_path + fi + done + if [[ ! $template ]]; then + echo "No local template found for name $arg" + exit 1 + fi + fi +done + +exec $G8 $branch $tag $directory $out $knownhosts $force $version $help $=args $template