From dd4e37d8a58d6a4f12eee048587b7daa792e4bee Mon Sep 17 00:00:00 2001 From: Valentin Boettcher Date: Fri, 5 Apr 2024 18:49:50 -0400 Subject: [PATCH] allow default options and overrides --- config.py | 5 ++--- config.toml | 8 ++++++++ nix/hm-module.nix | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 config.toml diff --git a/config.py b/config.py index 648a5ff..8638704 100644 --- a/config.py +++ b/config.py @@ -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) diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..86d1871 --- /dev/null +++ b/config.toml @@ -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] diff --git a/nix/hm-module.nix b/nix/hm-module.nix index 4e9634c..ac5abcf 100644 --- a/nix/hm-module.nix +++ b/nix/hm-module.nix @@ -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']