mirror of https://github.com/Hoffelhas/autodoist
Allow setting Todoist API key from environment variable
In the Docker world, secrets (e.g. passwords, API keys) are usually shared with an application as environment variables so that they can be imported from separate secure areas: in docker-compose you can specify a file where secrets are imported from as environment variables. Read the API key from the TODOIST_API_KEY environment variable first, then check the command-line argument. Signed-off-by: Christopher Obbard <chris.obbard@collabora.com>pull/31/head
parent
1312474e53
commit
f47e974c7c
|
@ -333,7 +333,7 @@ def initialise_api(args):
|
||||||
# Check we have a API key
|
# Check we have a API key
|
||||||
if not args.api_key:
|
if not args.api_key:
|
||||||
logging.error(
|
logging.error(
|
||||||
"\n\nNo API key set. Run Autodoist with '-a <YOUR_API_KEY>'\n")
|
"\n\nNo API key set. Run Autodoist with '-a <YOUR_API_KEY>' or set the environment variable TODOIST_API_KEY.\n")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Check if alternative end of day is used
|
# Check if alternative end of day is used
|
||||||
|
@ -1356,8 +1356,8 @@ def main():
|
||||||
# Main process functions.
|
# Main process functions.
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
formatter_class=make_wide(argparse.HelpFormatter, w=120, h=60))
|
formatter_class=make_wide(argparse.HelpFormatter, w=120, h=60))
|
||||||
parser.add_argument('-a', '--api_key',
|
parser.add_argument(
|
||||||
help='takes your Todoist API Key.', type=str)
|
'-a', '--api_key', help='takes your Todoist API Key.', default=os.environ.get('TODOIST_API_KEY'), type=str)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-l', '--label', help='enable next action labelling. Define which label to use.', type=str)
|
'-l', '--label', help='enable next action labelling. Define which label to use.', type=str)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
|
Loading…
Reference in New Issue