Add version callback and more help text

This commit is contained in:
grym 2022-04-29 11:54:11 -04:00
parent 1e741ef76f
commit aaf379e774
2 changed files with 21 additions and 1 deletions

View File

@ -1 +1 @@
__version__ = "0.1.0"
from oxo._version import __version__

View File

@ -4,11 +4,31 @@ from pathlib import Path
import httpx
import typer
from oxo import __version__
app = typer.Typer()
base_url = typer.Option("http://0x0.st", envvar="OXO_BASE_URL")
def version_callback(value: bool):
if value:
typer.echo(f"{__version__}")
raise typer.Exit()
@app.callback()
def main(
version: t.Optional[bool] = typer.Option(
None, "--version", callback=version_callback, is_eager=True
),
):
"""A command line utility for 0x0.st compliant pastebins.
Set `OXO_BASE_URL` if the base URL is not http://0x0.st.
"""
@app.command()
def files(
files: t.List[Path] = typer.Argument(