added usage
This commit is contained in:
parent
7c8acd5a27
commit
8f3b2b6ee1
1 changed files with 21 additions and 0 deletions
21
paperless.sh
Normal file → Executable file
21
paperless.sh
Normal file → Executable 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
|
||||
|
|
Loading…
Reference in a new issue