commit dec0e4a039ea8302082e86957230e3d29d9a1867 Author: anon <anon@anon.anon> Date: Fri Jan 27 23:23:54 2023 +0100 init diff --git a/mktemplate b/mktemplate new file mode 100755 index 0000000..c23c424 --- /dev/null +++ b/mktemplate @@ -0,0 +1,88 @@ +#!/bin/bash + +enable -n echo + +readonly NORMAL="\33[0m" +readonly BOLD="\33[1m" +readonly RED="\33[31m" +readonly GREEN="\33[32m" +readonly YELLOW="\33[33m" +readonly BLUE="\33[34m" + +readonly OPTERR="${Red}Unrecognized option supplied. Exiting...${NORMAL}" +readonly EOPTS="ho:i:lc:e:x:" + +TPL_DIR="${MKTEMPLATE_HOME}" +TPL_META_FILE="${TPL_DIR/}" +OUTPUT="" +TEMPLATE="" + +function usage() { + echo -e "${BOLD}mktemplate [options]${NORMAL}" + echo -e " -h : print this help message" + echo -e " -o [file] : specifies output name" + echo -e " -i [path] : override ${BOLD}${BLUE}\${MKTEMPLATE_HOME}${NORMAL}" + echo -e " -l : list existing template names" + echo -e " -c [temp] : clone; specifies that a template is going to be copied and which it is" + echo -e " -e [temp] : echo; like clone, but do not write to file, instead print to stdout" + echo -e " -x [temp] : create; specifes that a new template is going to be added to the library and what it shall be called" + echo -e "" + echo -e "${YELLOW}This script attempts to eliminate user overhead of frequently coping a file to varying locations.${NORMAL}" + echo -e "${YELLOW}Mktemplate internally attempts to read a variable called ${BOLD}${BLUE}\"\${MKTEMPLATE_HOME}\"${NORMAL}${YELLOW}.${NORMAL}" + echo -e "${YELLOW}This variable shall hold the path to the folder where templates are stored.${NORMAL}" + echo -e "${YELLOW}\"Templates\" are just files located at ${BOLD}${BLUE}\${MKTEMPLATEHOME}${NORMAL}${YELLOW}.${NORMAL}" + echo -e "${YELLOW}Text files are processed through ${BOLD}m4${NORMAL}." +} + +while getopts "$EOPTS" O; do + case "$O" in + h) usage; exit ;; + o) OUTPUT=${OPTARG} ;; + i) TPL_DIR=${OPTARG} ;; + l) ;; + e) ;; + c) ;; + x) ;; + *) echo -e "$OPTERR"; exit 1 ;; + esac +done + +OPTIND=1 +while getopts "$EOPTS" O; do + case "$O" in + h) ;; + o) ;; + i) ;; + l) ls --color=always -1 ${TPL_DIR}; exit 1 ;; + e) TEMPLATE=${OPTARG} ;; + c) TEMPLATE=${OPTARG} ;; + x) TEMPLATE=${OPTARG} ;; + *) echo -e "$OPTERR"; exit 1 ;; + esac +done + +[ -z "${MKTEMPLATE_HOME}" ] && TPL_DIR="${HOME}/mktemplate_home" +[ ! -d "${MKTEMPLATE_HOME}" ] && mkdir "${TPL_DIR}" +[ -z "${TEMPLATE}" ] && echo -e "${RED}No template specified. Unsure what to do. Quitting...${NORMAL}" && exit 1 +[ -z "${OUTPUT}" ] && OUTPUT="${TEMPLATE}" + +OPTIND=1 +while getopts "$EOPTS" O; do + case "$O" in + h) ;; + o) ;; + i) ;; + l) ;; + t) ;; + e) echo "$(source <(echo "echo \"$(< "${TPL_DIR}/${TEMPLATE}")\""))" ;; + c) + if [[ $(mimetype "${TPL_DIR}/${TEMPLATE}") =~ plain/ ]] || [[ $(mimetype "${TPL_DIR}/${TEMPLATE}") =~ text/ ]]; then + cp <(m4 "${TPL_DIR}/${TEMPLATE}") "${OUTPUT}" + else + cp "${TPL_DIR}/${TEMPLATE}" "${OUTPUT}" + fi + ;; + x) cp "${TEMPLATE}" "${TPL_DIR}/${OUTPUT}" ;; + *) echo -e "$OPTERR"; exit 1 ;; + esac +done diff --git a/test/TODO.list b/test/TODO.list new file mode 100644 index 0000000..9ccd267 --- /dev/null +++ b/test/TODO.list @@ -0,0 +1,3 @@ +/*--------------------------------------------Todos------------------------------------------------\\ +| +\\-------------------------------------------------------------------------------------------------*/ diff --git a/test/html.html b/test/html.html new file mode 100644 index 0000000..8faf8e7 --- /dev/null +++ b/test/html.html @@ -0,0 +1,17 @@ +<!DOCTYPE html> + <html> + <!-- + Creation Date: syscmd(date) + --> + <head> + <title>TITLE</title> + <meta charset="utf-8"> + <style> + </style> + </head> + <body> + <script> + </script> + </body> + </html> + diff --git a/test/script.py b/test/script.py new file mode 100644 index 0000000..e427375 --- /dev/null +++ b/test/script.py @@ -0,0 +1,9 @@ +#!/bin/python + +import sys + +def main(agv): + pass + +if __name__ == '__main__': + raise SystemExit(main(sys.argv[1:])) diff --git a/test/script.sh b/test/script.sh new file mode 100644 index 0000000..c53eddb --- /dev/null +++ b/test/script.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +enable -n echo + +readonly NORMAL="\33[0m" + +readonly BOLD="\33[1m" +readonly UNDERLINE="\33[4m" +readonly INVERSE="\33[7m" + +readonly BLACK="\33[30m" +readonly RED="\33[31m" +readonly GREEN="\33[32m" +readonly YELLOW="\33[33m" +readonly BLUE="\33[34m" +readonly MAGENTA="\33[35m" +readonly CYAN="\33[36m" +readonly WHITE="\33[37m" + +SCRIPT_NAME=$(basename $0) + +function usage(){ + echo -e "${BOLD}${SCRIPT_NAME} [options] [file]${NORMAL}" + echo -e " -h : print this help message" + echo -e "" +# echo -e "${YELLOW}${NORMAL}" +} + +OPTSTR="h" + +while getopts "${OPTSTR}" O; do + case $O in + h) usage && exit ;; + *) echo -e "${RED}Unrecognized option, exiting...${NORMAL}" && exit 1 ;; + esac +done +#OPTIND=0