GitHub

API reference for cli.

Command-line apps (Effect's effect/cli).

Declare a command's params as a Config class of Flag and Argument attributes, build commands with command.make, and run the tree with command.run; help, errors, --version, --completions and --wizard come built in::

from pyfect import console
from pyfect.cli import Argument, Config, Flag, command

class Greet(Config):
    name = Argument.string("name")
    loud = Flag.boolean("loud").with_alias("l").with_default(False)

def greet(config: Greet):
    text = f"Hello, {config.name}"
    return console.log(text.upper() if config.loud else text)

app = command.make("greet", Greet, greet)
program = command.run(app, version="1.0.0")

Modules: command, flag, argument, param, primitive, cli_error, cli_output, help_doc, global_flag, cli_config, completions, prompt, terminal_capabilities.

Re-exports

Classes

Functions

group

group[EG = Never, RG = Never](name, *commands) -> SubcommandGroup[EG, RG]
ParameterTypeDescription
namestr
commandsCommand[Any, Any, EG, RG] = ()

Returns SubcommandGroup[EG, RG]

def group[EG = Never, RG = Never](
    name: str, *commands: Command[Any, Any, EG, RG]
) -> SubcommandGroup[EG, RG]:
    return SubcommandGroup(name, commands)

nested

nested[C: Config](config) -> Nested[C]
ParameterTypeDescription
configtype[C]

Returns Nested[C]

def nested[C: Config](config: type[C]) -> Nested[C]:
    return Nested(config)

Modules