Source code for bundle.cli
# Copyright 2026 HorusElohim
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import rich_click as click
from bundle.core import logger, tracer
log = logger.get_logger(__name__)
click.rich_click.SHOW_ARGUMENTS = True
banner = """
╔═════════════════════════════════╗
║ T H E B U N D L E ║
╚═════════════════════════════════╝
"""
click.echo(click.style(banner, fg="green"))
@click.group(name="bundle")
@tracer.Sync.decorator.call_raise
async def main():
pass
@main.command()
@tracer.Sync.decorator.call_raise
async def version():
"""The Bundle Package version"""
try:
# generated by setuptools_scm into bundle/_version.py
from bundle._version import version
except ImportError:
version = "unknown"
log.info(f"Version: {version}")
[docs]
def add_cli_submodule(submodule_name: str) -> None:
"""Dynamically imports a subcommand and adds it to the CLI group.
Assumes each submodule has a `cli` module and within that module an attribute
with the same name as the submodule, e.g. `bundle.scraper.cli` has `scraper`.
Args:
submodule_name (str): The name of the submodule to import.
"""
try:
# Import the cli module from the submodule
module = __import__(f"bundle.{submodule_name}.cli", fromlist=[submodule_name])
command = getattr(module, submodule_name, None)
if command:
main.add_command(command)
else:
log.warning(f"Command '{submodule_name}' not found in module {module}.")
except ImportError as e:
log.warning(f"Module 'bundle.{submodule_name}.cli' could not be imported -> {e}")
add_cli_submodule("testing")
add_cli_submodule("scraper")
add_cli_submodule("website")
add_cli_submodule("youtube")
add_cli_submodule("pybind")
add_cli_submodule("ble")
add_cli_submodule("pods")
add_cli_submodule("discord")
add_cli_submodule("tracy")
add_cli_submodule("perf_report")
add_cli_submodule("docs")