File size: 1,132 Bytes
f824e2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
45
46
47
48
"""Root Typer application for hf-release."""

from __future__ import annotations

import typer
from rich.traceback import install as install_rich_tb

from . import __version__
from .commands.release import app as release_app
from .utils.display import console, print_error
from .utils.exceptions import HFReleaseError

# Never leak tokens in tracebacks
install_rich_tb(show_locals=False)

app = typer.Typer(
    name="hf-release",
    rich_markup_mode="rich",
    pretty_exceptions_show_locals=False,
    add_completion=True,
    help=(
        "[bold]hf-release[/bold] — publish model weights to [cyan]Hugging Face Hub[/cyan] "
        "and create a [green]GitHub Release[/green] in one atomic command."
    ),
)

app.add_typer(release_app, name="release")


def _version_callback(value: bool) -> None:
    if value:
        typer.echo(f"hf-release {__version__}")
        raise typer.Exit()


@app.callback()
def main(
    version: bool = typer.Option(
        False,
        "--version",
        "-V",
        callback=_version_callback,
        is_eager=True,
        help="Show version and exit.",
    ),
) -> None:
    pass