Skip to content

Commit

Permalink
feat(cli): add version command line flag to display version.
Browse files Browse the repository at this point in the history
  • Loading branch information
qkaiser committed Aug 11, 2023
1 parent 39ba033 commit 8869590
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions unblob/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ def restore_cursor():
sys.stdout.write("\033[?25h") # ANSI escape code to show cursor


def get_version():
return pkg_resources.get_distribution("unblob").version


def show_version(
ctx: click.Context, _param: click.Option, value: bool # noqa: FBT001
) -> None:
if not value or ctx.resilient_parsing:
return
click.echo(get_version())
ctx.exit(code=0)


def show_external_dependencies(
ctx: click.Context, _param: click.Option, value: bool # noqa: FBT001
) -> None:
Expand Down Expand Up @@ -198,6 +211,13 @@ def __init__(
callback=show_external_dependencies,
expose_value=False,
)
@click.option(
"--version",
help="Shows unblob version",
is_flag=True,
callback=show_version,
expose_value=False,
)
def cli(
file: Path,
extract_root: Path,
Expand Down

0 comments on commit 8869590

Please sign in to comment.