From 30980ddd9aed3fe31b8b8f9027c26a619639cd2e Mon Sep 17 00:00:00 2001
From: Maximilian Moser <maximilian.moser@tuwien.ac.at>
Date: Fri, 29 Jan 2021 13:27:02 +0100
Subject: [PATCH] cli: allow the value for --as-user to be specified as env var

* as fallback, the parameter --as-user/-u now reads its value from the
  environment variable INVENIO_UTILITIES_TUW_USER (if it is set)
* thus, the --as-user/-u parameter doesn't have to be specified for each
  command anymore
* the value is still required, s.t. either the env var or the CLI option
  have to be specified
---
 invenio_utilities_tuw/cli/options.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/invenio_utilities_tuw/cli/options.py b/invenio_utilities_tuw/cli/options.py
index e6379c4..de3be22 100644
--- a/invenio_utilities_tuw/cli/options.py
+++ b/invenio_utilities_tuw/cli/options.py
@@ -17,7 +17,12 @@ option_as_user = click.option(
     metavar="USER",
     default=None,
     required=True,
-    help="email address of the user to impersonate for the task",
+    envvar="INVENIO_UTILITIES_TUW_USER",
+    help=(
+        "email address of the user to impersonate for the task; "
+        "can also be specified via the environment variable "
+        "INVENIO_UTILITIES_TUW_USER"
+    ),
 )
 
 option_pid_type = click.option(
-- 
GitLab