added usage

This commit is contained in:
Tobias Schmidl 2024-11-14 10:12:32 +01:00
parent 7c8acd5a27
commit 8f3b2b6ee1

21
paperless.sh Normal file → Executable file
View file

@ -10,6 +10,23 @@ load_env () {
[ -z "$BASE_URL" ] && { echo "Parameter BASE_URL is not present in env file, please fill it with the URL of your paperless server." >&2; exit 1; }
}
print_usage () {
cat << END_OF_COMMENT
$(basename "$0") get_tasks | put_document <file>
commands:
get_tasks Get the list of tasks. This is not formatted, i.e. you'll
have to pipe it yourself through a formatter.
put_document Uploads the document under <file> to your paperless
instance.
return values:
If everything went alright, $(basename "$0") returns 0. Every other return
value indicates an error.
END_OF_COMMENT
}
AUTH_PARM="Authorization: Token $TOKEN"
case "$1" in
@ -22,4 +39,8 @@ case "$1" in
[ ! -r "$2" ] && { echo "file not readable." >&2; exit 1; }
curl -H "$AUTH_PARM" -X "POST" "${BASE_URL}/api/documents/post_document/" -H 'Accept: application/json' --form "document=@${2}"
;;
*)
print_usage
exit 1
;;
esac