Push Tracker
ria-toolkit-oss/src/ria_toolkit_oss_cli/cli.py
ben 0b75013653
All checks were successful
Build Sphinx Docs Set / Build Docs (pull_request) Successful in 16s
Build Project / Build Project (3.10) (pull_request) Successful in 57s
Build Project / Build Project (3.11) (pull_request) Successful in 54s
Build Project / Build Project (3.12) (pull_request) Successful in 2m17s
Test with tox / Test with tox (3.10) (pull_request) Successful in 2m51s
Test with tox / Test with tox (3.11) (pull_request) Successful in 4m44s
Test with tox / Test with tox (3.12) (pull_request) Successful in 8m39s
adressing feedback
2026-06-04 15:49:44 -04:00

63 lines
1.8 KiB
Python

"""
This module contains the main group for the ria toolkit oss CLI.
"""
import subprocess
import sys
import warnings
warnings.filterwarnings(
"ignore",
message="Unable to import Axes3D",
category=UserWarning,
module="matplotlib",
)
import click # noqa: E402
from ria_toolkit_oss_cli.ria_toolkit_oss import commands # noqa: E402
def _git_lfs_installed() -> bool:
"""Return True if git-lfs is available on PATH."""
try:
return (
subprocess.run(
["git", "lfs", "version"],
capture_output=True,
).returncode
== 0
)
except FileNotFoundError:
return False
@click.group(invoke_without_command=True)
@click.option("-v", "--verbose", is_flag=True, type=bool, help="Increase verbosity, especially useful for debugging.")
@click.pass_context
def cli(ctx, verbose):
lfs_missing = not _git_lfs_installed()
if lfs_missing:
click.echo(
"Warning: git-lfs is not installed. RIA Hub projects require git-lfs to\n"
"track large binary files (models, recordings, datasets).\n"
"\n"
" Linux: sudo apt-get install git-lfs\n"
" macOS: brew install git-lfs\n"
" Other platforms: https://git-lfs.com\n"
"\n"
"After installing, run: git lfs install",
err=True,
)
if ctx.invoked_subcommand is None:
if lfs_missing and sys.stdin.isatty():
click.pause(info="\nPress Enter to continue...", err=True)
click.echo(ctx.get_help())
# Loop through project commands, binding them all to the CLI.
for command_name in dir(commands):
command = getattr(commands, command_name)
if isinstance(command, click.Command):
cli.add_command(command, name=command_name)