feat: use configuration flow if not existing/not correct
This commit is contained in:
31
main.py
31
main.py
@@ -1,13 +1,42 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""Auditui entrypoint."""
|
"""Auditui entrypoint."""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from auditui.app import Auditui
|
from auditui.app import Auditui
|
||||||
from auditui.auth import authenticate
|
from auditui.auth import authenticate
|
||||||
|
from auditui.configure import configure
|
||||||
|
from auditui.constants import AUTH_PATH
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
"""Authenticate and launch the app."""
|
"""Authenticate and launch the app."""
|
||||||
auth, client = authenticate()
|
if len(sys.argv) > 1 and sys.argv[1] == "configure":
|
||||||
|
try:
|
||||||
|
configure()
|
||||||
|
print("Configuration completed successfully.")
|
||||||
|
except Exception as exc:
|
||||||
|
print(f"Configuration error: {exc}")
|
||||||
|
sys.exit(1)
|
||||||
|
return
|
||||||
|
|
||||||
|
config_dir = AUTH_PATH.parent
|
||||||
|
|
||||||
|
if not config_dir.exists():
|
||||||
|
print("No configuration yet, please run 'auditui configure' to create it")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
auth, client = authenticate()
|
||||||
|
except Exception as exc:
|
||||||
|
print(f"Authentication error: {exc}")
|
||||||
|
if not AUTH_PATH.exists():
|
||||||
|
print("No configuration yet, please run 'auditui configure' to create it")
|
||||||
|
else:
|
||||||
|
print("Please re-authenticate by running 'auditui configure'")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
app = Auditui(auth=auth, client=client)
|
app = Auditui(auth=auth, client=client)
|
||||||
app.run()
|
app.run()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user