From fd16ed7c86a0fad5a7472a0d9971299f5883f4cc Mon Sep 17 00:00:00 2001 From: Stefan Hagen Date: Wed, 29 Dec 2021 14:41:00 +0100 Subject: [PATCH] Worked around unfixed root cause of https://github.com/tiangolo/typer/issues/106 --- arbejdstimer/cli.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/arbejdstimer/cli.py b/arbejdstimer/cli.py index c8966229..428d4049 100644 --- a/arbejdstimer/cli.py +++ b/arbejdstimer/cli.py @@ -97,6 +97,16 @@ def now( return sys.exit(at.main(action)) +def explain_enforce_defaults(conf: str = '', verbose: bool = False) -> int: + """Until the root cause of https://github.com/tiangolo/typer/issues/106 remains unfixed.""" + command = 'explain' + if verbose: + command += '_verbatim' + config = conf if conf else pathlib.Path.home() / at.DEFAULT_CONFIG_NAME + action = [command, str(config)] + return sys.exit(at.main(action)) + + @app.command('explain') def explain( conf: str = typer.Option( @@ -118,12 +128,7 @@ def explain( Explain the answer to the question if now is a working hour (in addition to the return code 0 for yes, and 1 for no). """ - command = 'explain' - if verbose: - command += '_verbatim' - config = conf if conf else pathlib.Path.home() / at.DEFAULT_CONFIG_NAME - action = [command, str(config)] - return sys.exit(at.main(action)) + return explain_enforce_defaults(conf, verbose) @app.command('version')