diff --git a/gallagher/cli/__init__.py b/gallagher/cli/__init__.py index 8d2245a3..97f75a11 100644 --- a/gallagher/cli/__init__.py +++ b/gallagher/cli/__init__.py @@ -1,16 +1,32 @@ """ CLI entry point +gal is the gallagher command line, which is constructed using Typer. +At the moment typer does not support async functions, so we have to +use a wrapper to make it work. See utils.py for the AsyncTyper class. +The cli should be pretty self documenting, however see docs/ for +official documentation. """ -from gallagher import __version__ +import os + +from gallagher import ( + cc, + __version__ +) from .utils import AsyncTyper from .alarms import app as alarms_app from .cardholders import app as cardholders_app +# Load the API key for the package so all entry points +# can use it to query the service +api_key = os.environ.get("GACC_API_KEY") +cc.api_key = api_key + # Main Typer app use to create the CLI app = AsyncTyper() +# Load up all sub commands app.add_typer(alarms_app, name="alarms") app.add_typer(cardholders_app, name="ch") diff --git a/gallagher/cli/alarms.py b/gallagher/cli/alarms.py index 729f1c24..bc1dc811 100644 --- a/gallagher/cli/alarms.py +++ b/gallagher/cli/alarms.py @@ -3,13 +3,8 @@ """ -import os -from gallagher import cc from .utils import AsyncTyper -api_key = os.environ.get("GACC_API_KEY") - -cc.api_key = api_key app = AsyncTyper()