Skip to content

cli ¤

Module that contains the command line application.

Classes:

Functions:

  • main

    Run the main program.

  • print_and_exit

    Argument action callable to print something and exit immediately.

CommandCreate dataclass ¤

CommandCreate(
    *,
    help: bool = False,
    namespace: str,
    repo: str,
    description: str,
    repo_path: Path,
    insiders_repo_path: Path,
    insiders_namespace: str | None = None,
    insiders_repo: str | None = None,
    username: str | None = None,
    copier_template: str | None = None
)

Bases: HelpOption

Command to create public/insiders repositories.

Attributes:

  • copier_template (str | None) –

    Copier template to initialize the local insiders repository with.

  • description (str) –

    Shared description.

  • help (bool) –

    Print the program help and exit.

  • insiders_namespace (str | None) –

    Namespace of the insiders repository. Defaults to the public namespace.

  • insiders_repo (str | None) –

    Name of the insiders repository. Defaults to the public name.

  • insiders_repo_path (Path) –

    Local path in which to clone the insiders repository.

  • namespace (str) –

    Namespace of the public repository.

  • repo (str) –

    Name of the public repository.

  • repo_path (Path) –

    Local path in which to clone the public repository.

  • username (str | None) –

    Username. Defaults to the public namespace value.

copier_template class-attribute instance-attribute ¤

copier_template: str | None = None

Copier template to initialize the local insiders repository with.

description instance-attribute ¤

description: str

Shared description.

help class-attribute instance-attribute ¤

help: bool = False

Print the program help and exit.

insiders_namespace class-attribute instance-attribute ¤

insiders_namespace: str | None = None

Namespace of the insiders repository. Defaults to the public namespace.

insiders_repo class-attribute instance-attribute ¤

insiders_repo: str | None = None

Name of the insiders repository. Defaults to the public name.

insiders_repo_path instance-attribute ¤

insiders_repo_path: Path

Local path in which to clone the insiders repository.

namespace instance-attribute ¤

namespace: str

Namespace of the public repository.

repo instance-attribute ¤

repo: str

Name of the public repository.

repo_path instance-attribute ¤

repo_path: Path

Local path in which to clone the public repository.

username class-attribute instance-attribute ¤

username: str | None = None

Username. Defaults to the public namespace value.

CommandMain dataclass ¤

CommandMain(
    *,
    help: bool = False,
    subcommand: Subcommands[CommandCreate | CommandPyPI],
    version: bool = False,
    debug_info: bool = False,
    completion: bool = False
)

Bases: HelpOption

Command to manage your Insiders projects.

Attributes:

debug_info class-attribute instance-attribute ¤

debug_info: bool = False

Print debug information.

help class-attribute instance-attribute ¤

help: bool = False

Print the program help and exit.

subcommand instance-attribute ¤

subcommand: Subcommands[CommandCreate | CommandPyPI]

The selected subcommand.

CommandPyPI dataclass ¤

CommandPyPI(
    *,
    help: bool = False,
    subcommand: Subcommands[CommandPyPIRegister]
)

Bases: HelpOption

Command to manage PyPI-related things.

Attributes:

help class-attribute instance-attribute ¤

help: bool = False

Print the program help and exit.

subcommand instance-attribute ¤

subcommand: Subcommands[CommandPyPIRegister]

The selected subcommand.

CommandPyPIRegister dataclass ¤

CommandPyPIRegister(
    *,
    help: bool = False,
    username: str,
    name: str,
    description: str
)

Bases: HelpOption

Command to register a project name on PyPI.

Attributes:

description instance-attribute ¤

description: str

Description of the project on PyPI.

help class-attribute instance-attribute ¤

help: bool = False

Print the program help and exit.

name instance-attribute ¤

name: str

Name to register.

username instance-attribute ¤

username: str

Username on PyPI (your account).

HelpOption dataclass ¤

HelpOption(*, help: bool = False)

Reusable class to share a -h, --help option.

Attributes:

  • help (bool) –

    Print the program help and exit.

help class-attribute instance-attribute ¤

help: bool = False

Print the program help and exit.

main ¤

main(args: list[str] | None = None) -> int

Run the main program.

This function is executed when you type insiders or python -m insiders.

Parameters:

  • args (list[str] | None, default: None ) –

    Arguments passed from the command line.

Returns:

  • int

    An exit code.

Source code in src/insiders/cli.py
300
301
302
303
304
305
306
307
308
def main(
    args: An[list[str] | None, Doc("Arguments passed from the command line.")] = None,
) -> An[int, Doc("An exit code.")]:
    """Run the main program.

    This function is executed when you type `insiders` or `python -m insiders`.
    """
    output = cappa.Output(error_format=f"[bold]{NAME}[/]: [bold red]error[/]: {{message}}")
    return cappa.invoke(CommandMain, argv=args, output=output, backend=cappa.backend, completion=False, help=False)

print_and_exit ¤

print_and_exit(
    func: Callable[[], str | None], code: int = 0
) -> Callable[[], None]

Argument action callable to print something and exit immediately.

Parameters:

  • func (Callable[[], str | None]) –

    A function that returns or prints a string.

  • code (int, default: 0 ) –

    The status code to exit with.

Source code in src/insiders/cli.py
29
30
31
32
33
34
35
36
37
38
39
def print_and_exit(
    func: An[Callable[[], str | None], Doc("A function that returns or prints a string.")],
    code: An[int, Doc("The status code to exit with.")] = 0,
) -> Callable[[], None]:
    """Argument action callable to print something and exit immediately."""

    @wraps(func)
    def _inner() -> None:
        raise cappa.Exit(func() or "", code=code)

    return _inner