-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
37 lines (26 loc) · 949 Bytes
/
cli.py
File metadata and controls
37 lines (26 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""Define the CLI related functions and classes."""
from __future__ import annotations
from typing import Optional
import typer
from python_template import __version__
app = typer.Typer(help="This is a python template.")
def version_callback(value: bool) -> None: # noqa: FBT001
"""Handle the version callback."""
if value:
typer.secho(f"python-template version: {__version__}", fg=typer.colors.BRIGHT_GREEN, bold=True)
raise typer.Exit
@app.command()
def main(
# UP007 ignored here due to: https://github.com/tiangolo/typer/pull/522
version: Optional[bool] = typer.Option( # noqa: B008, UP007
None,
"--version",
callback=version_callback,
is_eager=True,
help="Display the current python template version",
),
) -> None:
"""Run the main python template logic."""
pass
if __name__ == "__main__": # pragma: no cover
app(prog_name="python-template")