shift opts, add output and source dir

This commit is contained in:
fanyx 2021-07-23 15:45:48 +02:00
parent 1e17c19038
commit 9938a57ebb
1 changed files with 12 additions and 12 deletions

24
mkshare
View File

@ -2,9 +2,8 @@
set -e
BASE="$0"
SHARE_DIR=""
SOURCE_DIR=""
output_dir=""
source_dir=""
compress="false"
expire="false"
@ -29,17 +28,10 @@ common options:
[ $# -eq 0 ] && print_usage && exit 1
# parse flags
# c: compress
# use zip to compress files or directories and put link to created zip file
# e: expire
# use ISO-8061 datetime string to set expiry date
# default expiry date is 7 days from creation
# h: help
# print usage
# s: shorten
# s: shorten (optional)
# generate random string of characters using `head /dev/urandom | tr -dc A-Za-z0-9 | head -c16`
while getopts ':cehs' flag; do
while getopts 'cehso:d' flag; do
case "$flag" in
h) print_usage ;;
c)
@ -62,6 +54,14 @@ while getopts ':cehs' flag; do
s)
shorten="true"
;;
o)
# NEEDS REALPATH VERIFICATION
output_dir="${OPTARG}"
;;
d)
# NEEDS REALPATH VERIFICATION
source_dir="${OPTARG}"
;;
?)
echo "Invalid option: -${OPTARG}"
echo