From 55626cf414f947be0ce5c8300f97f99421c2e222 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Mon, 24 Jun 2024 05:41:52 +0300 Subject: Reworked tempassin to lib/_ak_script --- bin/ak-tempassin | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'bin/ak-tempassin') diff --git a/bin/ak-tempassin b/bin/ak-tempassin index 6831dc2..42042f7 100755 --- a/bin/ak-tempassin +++ b/bin/ak-tempassin @@ -1,14 +1,33 @@ #!/bin/bash -AK_TEMP="$(mktemp -d /tmp/aktmp-XXXXXXX)" -PROGRAM="$(basename $0)" +## +## ak-tempassin: a `mktemp` interface +## +## Usage: +## +## -h, --help Prints this help message +## +## -f, --file Creates a temporary file and output fullpath +## +## -d, --dir Makes a temporary directory and returns its +## fullpath +## +fullprogrampath="$(realpath $0)" +PROGRAM=$(basename $0) +descriptionString="Temp file/dir creator" + +# At least these source $AK_LIBDIR/_ak_log +source $AK_LIBDIR/_ak_script -if [ ! -d "$AK_TEMP" ] +# Flags to run +if [ ! -z $1 ] then - _ak_log_error "Could not make $AK_TEMP directory to work in" - echo "Could not make $AK_TEMP directory to work in" - exit 1 + case $1 in + -h | --help) _ak_usage; exit;; + -d | --dir) _ak_make_temp_directory; exit;; + -f | --file) _ak_make_temp_file; exit;; + * ) _ak_usage;; + esac +else _ak_usage fi -_ak_log_info "$AK_TEMP created successfully" -echo "$AK_TEMP" -- cgit v1.2.3