From 8f3b2b6ee16eed03c4e67f1ac55e28f09477321f Mon Sep 17 00:00:00 2001 From: Tobias Schmidl Date: Thu, 14 Nov 2024 10:12:32 +0100 Subject: [PATCH] added usage --- paperless.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) mode change 100644 => 100755 paperless.sh diff --git a/paperless.sh b/paperless.sh old mode 100644 new mode 100755 index 76232a1..d2befa8 --- a/paperless.sh +++ b/paperless.sh @@ -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 + + 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 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