aboutsummaryrefslogtreecommitdiff
path: root/.local/templates
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2019-10-23 11:33:52 +0200
committerPatrick Spek <p.spek@tyil.nl>2019-10-23 11:33:52 +0200
commit2fcb8a91326581dc4f90495b472ccea94415ce6d (patch)
tree081a1cc09e685396be749f191411f4671d522785 /.local/templates
parentd2243899205a271883e7f922d6988637be00ac77 (diff)
Add basic templating tool
Diffstat (limited to '.local/templates')
-rw-r--r--.local/templates/sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/.local/templates/sh b/.local/templates/sh
new file mode 100644
index 0000000..ff7bc6d
--- /dev/null
+++ b/.local/templates/sh
@@ -0,0 +1,46 @@
+#! /usr/bin/env sh
+
+main()
+{
+ # Handle opts
+ opts "$@"
+ shift "$OPTS"
+ unset "$OPTS"
+
+ # Show help
+ [ "$OPT_HELP_ONLY" ] && usage && exit 0
+
+ # TODO: Write actual program
+}
+
+opts()
+{
+ OPTS=0
+
+ while getopts ":h" opt
+ do
+ case "$opt" in
+ h) OPT_HELP_ONLY=1
+ *)
+ printf "Invalid option passed: %s\n" "$OPTARG" >&2
+ ;;
+ esac
+ done
+
+ unset opt
+}
+
+usage()
+{
+ cat <<EOF
+Usage:
+ $(basename "$0") -h
+
+Nondescript
+
+Options:
+ -h Show this help text and exit.
+EOF
+}
+
+main "$@"