Push Tracker
ria-toolkit-oss/src/ria_toolkit_oss_cli/cli.py

59 lines
1.7 KiB
Python
Raw Normal View History

G
2025-12-09 12:40:55 -05:00
"""
This module contains the main group for the ria toolkit oss CLI.
G
2025-12-09 12:40:55 -05:00
"""
2026-06-03 16:25:47 -04:00
import subprocess
2026-06-04 09:15:20 -04:00
import warnings
warnings.filterwarnings(
"ignore",
message="Unable to import Axes3D",
category=UserWarning,
module="matplotlib",
)
2026-06-03 16:25:47 -04:00
G
2025-12-09 12:40:55 -05:00
import click
G
2025-12-15 13:51:17 -05:00
from ria_toolkit_oss_cli.ria_toolkit_oss import commands
G
2025-12-09 12:40:55 -05:00
2026-06-03 16:25:47 -04:00
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
2026-06-03 16:43:02 -04:00
@click.group(invoke_without_command=True)
G
2025-12-09 12:40:55 -05:00
@click.option("-v", "--verbose", is_flag=True, type=bool, help="Increase verbosity, especially useful for debugging.")
2026-06-03 16:43:02 -04:00
@click.pass_context
def cli(ctx, verbose):
2026-06-04 09:15:20 -04:00
lfs_missing = not _git_lfs_installed()
if lfs_missing:
2026-06-03 16:25:47 -04:00
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,
)
2026-06-03 16:43:02 -04:00
if ctx.invoked_subcommand is None:
2026-06-04 09:15:20 -04:00
if lfs_missing:
click.pause(info="\nPress Enter to continue...", err=True)
2026-06-03 16:43:02 -04:00
click.echo(ctx.get_help())
G
2025-12-09 12:40:55 -05:00
# 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)