Skip to content

Xil Use

src.xil_pipeline.xil_use

xil use — set or display the active show context.

Usage::

xil use                         # list available shows, mark active one
xil use "The Woonsocket Wonders" # set by show name
xil use thewoonsocketwonders      # set by slug

logger module-attribute

logger = get_logger(__name__)

get_parser

get_parser() -> argparse.ArgumentParser

Return the argument parser for xil-use.

Source code in src/xil_pipeline/xil_use.py
def get_parser() -> argparse.ArgumentParser:
    """Return the argument parser for xil-use."""
    parser = argparse.ArgumentParser(
        prog="xil-use",
        description=(
            "Set or display the active show context. Without arguments, lists all "
            "shows discovered in the workspace (each configs/<slug>/project.json) "
            "and marks the currently active show with an asterisk. With a show "
            "name or slug, switches the active show; subsequent commands that "
            "auto-detect the show (parse, produce, status, ...) use it until "
            "changed again."
        ),
        epilog=(
            "The active show is stored in <workspace>/.active_show. A multi-word "
            "show name may be given unquoted; all arguments are joined with spaces."
        ),
    )
    parser.add_argument(
        "show",
        nargs="*",
        help="show name or slug to activate (omit to list available shows)",
    )
    return parser

main

main() -> int

CLI entry point for the active-show context switcher.

Source code in src/xil_pipeline/xil_use.py
def main() -> int:
    """CLI entry point for the active-show context switcher."""
    configure_logging()
    args = get_parser().parse_args().show

    root = get_workspace_root()
    shows = _available_shows(root)
    current = get_active_show()

    if not args:
        if not shows:
            logger.info("No shows found. Run 'xil init --show \"My Show\"' to create one.")
            return 0
        logger.info("Available shows (* = active):")
        for slug, name in shows:
            marker = "* " if slug == current else "  "
            logger.info("  %s%s  (%s)", marker, name, slug)
        if current and not any(s == current for s, _ in shows):
            logger.warning("Active show '%s' has no project.json in configs/.", current)
        return 0

    query = " ".join(args).strip()
    query_slug = show_slug(query)

    # Match by slug first, then by show name slug
    matched_slug = None
    matched_name = None
    for slug, name in shows:
        if slug == query_slug or slug == query or show_slug(name) == query_slug:
            matched_slug = slug
            matched_name = name
            break

    if matched_slug is None:
        logger.error("No show matching '%s'. Run 'xil use' to list available shows.", query)
        return 1

    set_active_show(matched_slug)
    logger.info("Active show: %s  (%s)", matched_name, matched_slug)
    return 0