Skip to content

Commit

Permalink
refactor: move configuration to package root
Browse files Browse the repository at this point in the history
moves the environment variable configuration to the root of the package
clean up various imports post asyncio workaround, see previous commit
for details on how typer asyncio works

REFS #18 #13
  • Loading branch information
devraj committed Dec 18, 2023
1 parent 620b652 commit 0c0c959
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
18 changes: 17 additions & 1 deletion gallagher/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -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")

Expand Down
5 changes: 0 additions & 5 deletions gallagher/cli/alarms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 0c0c959

Please sign in to comment.