Skip to content

Commit

Permalink
Worked around unfixed root cause of fastapi/typer#106
Browse files Browse the repository at this point in the history
  • Loading branch information
sthagen committed Dec 29, 2021
1 parent e22c4f5 commit fd16ed7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions arbejdstimer/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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')
Expand Down

0 comments on commit fd16ed7

Please sign in to comment.