Skip to content

Commit cece6b1

Browse files
committed
using callback to run version and exit.
1 parent cfe421c commit cece6b1

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

src/wristpy/core/cli.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@
1515
)
1616

1717

18+
@app.callback(invoke_without_command=True)
19+
def version_check(
20+
version: bool = typer.Option(
21+
False,
22+
"-V",
23+
"--version",
24+
help="Check the current version of wristpy and exist.",
25+
is_eager=True,
26+
),
27+
) -> None:
28+
"""Print current version of wristpy and exit."""
29+
if version:
30+
typer.echo(f"Wristpy version: {config.get_version()}")
31+
raise typer.Exit()
32+
33+
1834
class OutputFileType(str, Enum):
1935
"""Valid output file types for saving data."""
2036

@@ -54,13 +70,6 @@ class NonwearAlgorithms(str, Enum):
5470
detach = "detach"
5571

5672

57-
def version_callback(version: bool):
58-
"""Check the version independently."""
59-
if version:
60-
typer.echo(f"Wristpy version: {config.get_version()}")
61-
raise typer.Exit()
62-
63-
6473
@app.command()
6574
def main(
6675
input: pathlib.Path = typer.Argument(
@@ -129,15 +138,6 @@ def main(
129138
help="Determines the level of verbosity. Use -v for info, -vv for debug. "
130139
"If -vvv or more, it will be set to debug. "
131140
"Default for warning.",
132-
callback=version_callback,
133-
),
134-
version: bool = typer.Option(
135-
False,
136-
"-V",
137-
"--version",
138-
help="Show the version and exit.",
139-
callback=version_callback,
140-
is_eager=True,
141141
),
142142
) -> None:
143143
"""Run wristpy orchestrator with command line arguments."""

0 commit comments

Comments
 (0)