From 24c3aeb4422d393b01773d4676237555a1ad3ed3 Mon Sep 17 00:00:00 2001 From: Philipp Emanuel Weidmann Date: Sun, 7 Dec 2025 11:37:07 +0530 Subject: [PATCH] feat: turn boolean settings into CLI flags --- src/heretic/config.py | 1 + src/heretic/main.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/heretic/config.py b/src/heretic/config.py index b19b3fb..a69c059 100644 --- a/src/heretic/config.py +++ b/src/heretic/config.py @@ -213,6 +213,7 @@ class Settings(BaseSettings): toml_file="config.toml", env_prefix="HERETIC_", cli_parse_args=True, + cli_implicit_flags=True, cli_kebab_case=True, ) diff --git a/src/heretic/main.py b/src/heretic/main.py index fef36a7..34e8561 100644 --- a/src/heretic/main.py +++ b/src/heretic/main.py @@ -65,10 +65,11 @@ def run(): print() if ( - # An odd number of arguments have been passed (argv[0] is the program name), - # so that after accounting for "--param VALUE" pairs, there is one left over. - len(sys.argv) % 2 == 0 - # The leftover argument is a parameter value rather than a flag (such as "--help"). + # There is at least one argument (argv[0] is the program name). + len(sys.argv) > 1 + # No model has been explicitly provided. + and "--model" not in sys.argv + # The last argument is a parameter value rather than a flag (such as "--help"). and not sys.argv[-1].startswith("-") ): # Assume the last argument is the model.