allow default options and overrides

This commit is contained in:
Valentin Boettcher 2024-04-05 18:49:50 -04:00
parent f85a1900b7
commit dd4e37d8a5
No known key found for this signature in database
GPG key ID: E034E12B7AF56ACE
3 changed files with 11 additions and 4 deletions

View file

@ -8,10 +8,9 @@ def get_config(profile):
with open(Path.home() / ".o365-auth-config.toml", "rb") as f:
toplevel_data = tomllib.load(f)
if profile not in toplevel_data:
sys.exit("Invalid profile specified.")
config_data = toplevel_data[profile]
default_data = toplevel_data["default"]
config_data = default_data | toplevel_data.get(profile, {})
cache_path = Path.home() / ".cache/o365-oauth" / profile
cache_path.mkdir(parents=True, exist_ok=True)

8
config.toml Normal file
View file

@ -0,0 +1,8 @@
[default]
ClientId = "08162f7c-0fd2-4200-a84a-f25a4db0b584"
ClientSecret = "TxRBilcHdC6WGBee]fs?QR:SJ8nI[g82"
Scopes = ['https://outlook.office.com/IMAP.AccessAsUser.All','https://outlook.office.com/SMTP.Send']
Authority = false
[mcgill]

View file

@ -20,7 +20,7 @@ in
config = mkOption {
type = types.str;
default = ''
[mcgill]
[default]
ClientId = "08162f7c-0fd2-4200-a84a-f25a4db0b584"
ClientSecret = "TxRBilcHdC6WGBee]fs?QR:SJ8nI[g82"
Scopes = ['https://outlook.office.com/IMAP.AccessAsUser.All','https://outlook.office.com/SMTP.Send']