Skip to content

Commit

Permalink
specify default behavior to use "browse" if not recognized as subcomm…
Browse files Browse the repository at this point in the history
…and (#158)

* add default click group to specify browse command

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix(types): Ignore DefaultGroup when typing

Signed-off-by: Henry Schreiner <[email protected]>

* Update README.md

---------

Signed-off-by: Henry Schreiner <[email protected]>
Co-authored-by: Orion Yeung <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Henry Schreiner <[email protected]>
  • Loading branch information
4 people committed Nov 28, 2023
1 parent 2663beb commit 59b87e5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pipx run uproot-browser

uproot-browser currently provides the following features (get help with `-h` or `--help`, view the current version with `--version`):

- `browse` can be used to display a TUI (text user interface).
- `browse` can be used to display a TUI (text user interface), acts as default if no subcommand specified.
- `plot` can be used to display a plot.
- `tree` can be used to display a tree.

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dynamic = ["version"]
dependencies = [
'awkward >=1',
'click >=8',
'click-default-group >=1.2',
'hist >=2.4',
'importlib_resources; python_version<"3.9"',
'lz4',
Expand Down
14 changes: 10 additions & 4 deletions src/uproot_browser/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import functools
import os
import typing
from pathlib import Path
from typing import Any, Callable

Expand All @@ -18,8 +19,13 @@

VERSION = __version__

if typing.TYPE_CHECKING:
DefaultGroup = click.Group
else:
from click_default_group import DefaultGroup

@click.group(context_settings=CONTEXT_SETTINGS)

@click.group(context_settings=CONTEXT_SETTINGS, cls=DefaultGroup, default="browse")
@click.version_option(version=VERSION)
def main() -> None:
"""
Expand All @@ -28,7 +34,7 @@ def main() -> None:


@main.command()
@click.argument("filename")
@click.argument("filename", type=click.Path(exists=True))
def tree(filename: str) -> None:
"""
Display a tree.
Expand All @@ -53,7 +59,7 @@ def new_func(*args: Any, **kwargs: Any) -> Any:


@main.command()
@click.argument("filename")
@click.argument("filename", type=click.Path(exists=True))
@click.option(
"--iterm", is_flag=True, help="Display an iTerm plot (requires [iterm] extra)."
)
Expand Down Expand Up @@ -94,7 +100,7 @@ def plot(filename: str, iterm: bool) -> None:


@main.command()
@click.argument("filename")
@click.argument("filename", type=click.Path(exists=True))
def browse(filename: str) -> None:
"""
Display a TUI.
Expand Down

0 comments on commit 59b87e5

Please sign in to comment.