""" This module contains the main group for the ria toolkit oss CLI. """ import subprocess import sys import click from ria_toolkit_oss_cli.ria_toolkit_oss import commands 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): if not _git_lfs_installed(): 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: 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)