Browse Source

code shuffle; quiet flag

Signed-off-by: fbt <fbt@fleshless.org>
master
Jack L. Frost 6 years ago
parent
commit
b5331d8c93
  1. 56
      ufw

56
ufw

@ -15,8 +15,13 @@ is_url() {
[[ "$1" =~ $cfg_url_regex ]]
}
msg() { printf '%s\n' "[ufw] $1"; }
err() { msg "(error) $1" >&2; }
msg() {
if ! (( flag_quiet )); then
printf '%s\n' "$1"
fi
}
err() { printf '(error) %s\n' "$*" >&2; }
usage() {
_cat <<- EOF
@ -47,12 +52,6 @@ usage() {
EOF
}
ensure_env() {
for i in "$cfg_tmp_dir"; do
[[ -d "$i" ]] || { mkdir -p "$i"; }
done
}
get_file_hash() {
read file_hash _ < <( sha1sum "$1" )
}
@ -341,53 +340,52 @@ main() {
while [[ "$1" ]]; do
case "$1" in
-p|--public) flag_private='false';;
-R|--remove-file) flag_rm='1';;
-s|--screenshot) flag_scrot='1';;
-h|--help|--usage) usage; return;;
-D|--screenshot-delay) cfg_scrot_delay="$2"; shift;;
-F|--fullscreen)
flag_scrot='1'
flag_scrot_fullscreen='1'
;;
-m|--max-filesize) cfg_max_filesize=$2; shift;;
-A|--album-name) album_name=$2; shift;;
-i|--my-ip) action='getmyip';;
-u|--shorten) action='url';;
-p|--public) flag_private='false';;
-R|--remove-file) flag_rm='1';;
-s|--screenshot) flag_scrot='1';;
-S|--short-url) flag_shortlink=1;;
-P|--page-url) flag_directlink=0;;
-q|--quiet) flag_quiet=1;;
-F|--fullscreen)
flag_scrot='1'
flag_scrot_fullscreen='1'
;;
-a|--album-id)
misc_curl_args+=( -F "album_id=$2" )
shift
;;
-A|--album-name) album_name=$2; shift;;
-d|--description)
misc_curl_args+=( -F "description=$2" )
shift
;;
-l|--login)
action='login'
login=$2
shift
;;
-h|--help|--usage) usage; return;;
--) shift; break;;
-*)
err "Unknown flag: $1"
usage
return 1
;;
*) break;;
esac
shift
done
ensure_env
for i in "$cfg_tmp_dir"; do
[[ -d "$i" ]] || { mkdir -p "$i"; }
done
case "${action:-upload}" in
upload) upload "$1";;

Loading…
Cancel
Save