← GDG /

#043 gdtest_cli_click

#043 gdtest_cli_click OK CONFIG
Simple Click CLI commands with CLI docs enabled
A package with Click CLI commands and cli.enabled=true in config. The sidebar should show a CLI Reference section alongside the API Reference. The CLI reference page should document the Click commands. The API Reference should show Formatter (class) and format_text (function).
View Site → Build Log ๐Ÿงช Test Coverage

Build Mode

● Has great-docs.yml

This package ships a pre-supplied config. The great-docs init step is skipped and great-docs build uses the spec-defined configuration directly. Tests specific config options and their rendered output.

Dimensions

A1 B1 C1 D1 E1 E6 F6 G1 H7
A1Flat layoutlayout
B1Explicit __all__exports
C1Functions onlyobjects
D1NumPydocstrings
E1E1
E6No directivesdirectives
F6No user guideuser_guide
G1README.mdlanding
H7No extrasextras

Source Files

๐Ÿ“ gdtest_cli_click/
๐Ÿ“„ __init__.py
"""A package with Click CLI support."""

__version__ = "0.1.0"
__all__ = ["Formatter", "format_text"]


class Formatter:
    """
    A text formatter.

    Parameters
    ----------
    style
        The formatting style to use.
    """

    def __init__(self, style: str = "default"):
        self.style = style

    def apply(self, text: str) -> str:
        """
        Apply formatting to text.

        Parameters
        ----------
        text
            The text to format.

        Returns
        -------
        str
            Formatted text.
        """
        return text


def format_text(text: str, style: str = "default") -> str:
    """
    Format text with a given style.

    Parameters
    ----------
    text
        The text to format.
    style
        The style to apply.

    Returns
    -------
    str
        Formatted text.
    """
    return Formatter(style).apply(text)
๐Ÿ“„ cli.py
"""CLI entry point using Click."""

import click


@click.command()
@click.argument("text")
@click.option("--style", "-s", default="default", help="Formatting style.")
@click.option("--verbose", "-v", is_flag=True, help="Verbose output.")
def main(text: str, style: str, verbose: bool) -> None:
    """Format text using the gdtest-cli-click formatter."""
    if verbose:
        click.echo(f"Formatting with style: {style}")
    click.echo(text)
๐Ÿ“„ README.md
# gdtest-cli-click

A test package with Click CLI support.
๐Ÿ“„ great-docs.yml
cli:
  enabled: true