diff --git a/src/bilifm/__main__.py b/src/bilifm/__main__.py new file mode 100644 index 0000000..021ca49 --- /dev/null +++ b/src/bilifm/__main__.py @@ -0,0 +1,3 @@ +from .command import app + +app() diff --git a/src/bilifm/__version__.py b/src/bilifm/__version__.py new file mode 100644 index 0000000..fd95cf9 --- /dev/null +++ b/src/bilifm/__version__.py @@ -0,0 +1,9 @@ +import sys + +if sys.version_info >= (3, 10): + import importlib.metadata as importlib_metadata +else: + import importlib_metadata + + +__version__ = importlib_metadata.version("bilifm") diff --git a/src/bilifm/command.py b/src/bilifm/command.py index c51c23b..5b08f7d 100644 --- a/src/bilifm/command.py +++ b/src/bilifm/command.py @@ -2,6 +2,7 @@ import typer +from .__version__ import __version__ from .audio import Audio from .fav import Fav from .season import Season @@ -12,6 +13,17 @@ app = typer.Typer() +@app.callback(invoke_without_command=True) +def callback(version: bool = False): + """ + Entry for public options + """ + + if version: + typer.echo(f"ppatch, version {__version__}") + raise typer.Exit() + + @app.command() def bv( bv: str,