Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specify default behavior to use "browse" if not recognized as subcommand #158

Merged
merged 4 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
henryiii marked this conversation as resolved.
Show resolved Hide resolved
- `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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, missed these. It's not correct, this is a path maybe followed by aa colon then stuff.

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