cornflakes.decorator.click.rich package

Module contents

cornflakes.click.rich Module.

class cornflakes.decorator.click.rich.RichArg(*args, **kwargs)[Quellcode]

Bases: Argument

A custom argument implementation of click.

Argument class in order to provide a short help message for each argument of a command.

class cornflakes.decorator.click.rich.RichCommand(*args, config=None, **kwargs)[Quellcode]

Bases: Command

Richly formatted click Command.

Inherits click.Command and overrides help and error methods to print richly formatted output.

Parameter:

config (RichConfig) –

allow_extra_args = True

the default for the Context.allow_extra_args flag.

allow_interspersed_args = False

the default for the Context.allow_interspersed_args flag.

callback()[Quellcode]

Callback method with is wrapped over the command.

config: RichConfig
context_settings: dict

an optional dictionary with defaults passed to the context.

format_help(ctx, formatter)[Quellcode]

Format function of RichGroup.

Parameter:
  • ctx (Context) –

  • formatter (HelpFormatter) –

Rückgabetyp:

None

ignore_unknown_options = False

the default for the Context.ignore_unknown_options flag.

main(*args, standalone_mode=True, **kwargs)[Quellcode]

Main function of RichGroup.

Parameter:

standalone_mode (bool) –

Rückgabetyp:

Any

name = ''

the name the command thinks it has. Upon registering a command on a Group the group will default the command name with this information. You should instead use the Context's info_name attribute.

params: List[Parameter]

the list of parameters for this command in the order they should show up in the help page and execute. Eager parameters will automatically be handled before non eager ones.

parent = None
standalone_mode = False
class cornflakes.decorator.click.rich.RichConfig(STYLE_OPTION='bold cyan', STYLE_ARGUMENT='bold cyan', STYLE_SWITCH='bold green', STYLE_METAVAR='bold yellow', STYLE_METAVAR_APPEND='dim yellow', STYLE_METAVAR_SEPARATOR='dim', STYLE_HEADER_TEXT='', STYLE_FOOTER_TEXT='', STYLE_USAGE='yellow', STYLE_USAGE_COMMAND='bold', STYLE_DEPRECATED='red', STYLE_HELPTEXT_FIRST_LINE='', STYLE_HELPTEXT='dim', STYLE_OPTION_HELP='', STYLE_OPTION_DEFAULT='dim', STYLE_OPTION_ENVVAR='dim yellow', STYLE_REQUIRED_SHORT='red', STYLE_REQUIRED_LONG='dim red', STYLE_OPTIONS_PANEL_BORDER='dim', ALIGN_OPTIONS_PANEL='left', STYLE_OPTIONS_TABLE_SHOW_LINES=False, STYLE_OPTIONS_TABLE_LEADING=0, STYLE_OPTIONS_TABLE_PAD_EDGE=False, STYLE_OPTIONS_TABLE_PADDING=(0, 1), STYLE_OPTIONS_TABLE_SHOW_EDGE=True, STYLE_OPTIONS_TABLE_BOX='', STYLE_OPTIONS_TABLE_ROW_STYLES=None, STYLE_OPTIONS_TABLE_HEADER_STYLE='table.header', STYLE_OPTIONS_TABLE_BORDER_STYLE=None, STYLE_COMMANDS_PANEL_BORDER='dim', ALIGN_COMMANDS_PANEL='left', STYLE_COMMANDS_TABLE_SHOW_LINES=False, STYLE_COMMANDS_TABLE_LEADING=0, STYLE_COMMANDS_TABLE_PAD_EDGE=False, STYLE_COMMANDS_TABLE_PADDING=(0, 1), STYLE_COMMANDS_TABLE_BOX='', STYLE_COMMANDS_TABLE_ROW_STYLES=None, STYLE_COMMANDS_TABLE_BORDER_STYLE=None, STYLE_ERRORS_PANEL_BORDER='red', ALIGN_ERRORS_PANEL='left', STYLE_ERRORS_SUGGESTION='dim', STYLE_ABORTED='red', MAX_WIDTH=None, COLOR_SYSTEM='auto', FORCE_TERMINAL=None, HEADER_TEXT=None, HEADER_LOGO=None, FOOTER_TEXT=None, DEPRECATED_STRING='(Deprecated) ', DEFAULT_STRING='[default: {}]', ENVVAR_STRING='[env var: {}]', REQUIRED_SHORT_STRING='*', REQUIRED_LONG_STRING='[required]', RANGE_STRING=' [{}]', APPEND_METAVARS_HELP_STRING='({})', ARGUMENTS_PANEL_TITLE='Arguments', OPTIONS_PANEL_TITLE='Options', COMMANDS_PANEL_TITLE='Commands', ERRORS_PANEL_TITLE='Error', ERRORS_SUGGESTION=None, ERRORS_EPILOGUE=None, ABORTED_TEXT='Aborted.', SHOW_ARGUMENTS=True, SHOW_METAVARS_COLUMN=True, APPEND_METAVARS_HELP=False, APPEND_METAVARS_REQUIRED=False, GROUP_ARGUMENTS_OPTIONS=False, OPTION_ENVVAR_FIRST=False, USE_RST=False, SHOW_RST_ERRORS=False, USE_MARKDOWN=False, USE_MARKDOWN_EMOJI=True, USE_RICH_MARKUP=False, CODE_THEME='monokai', USE_CLICK_SHORT_HELP=False, VERSION_INFO=False, VERBOSE_OPTION=False, BG_PROCESS_OPTION=False, files=None, sections=None, eval_env=None, allow_empty=False, init_from_default_cache=False, **kwargs)[Quellcode]

Bases: object

DataClass for click config-values.

Parameter:
  • STYLE_OPTION (str) –

  • STYLE_ARGUMENT (str) –

  • STYLE_SWITCH (str) –

  • STYLE_METAVAR (str) –

  • STYLE_METAVAR_APPEND (str) –

  • STYLE_METAVAR_SEPARATOR (str) –

  • STYLE_HEADER_TEXT (str) –

  • STYLE_FOOTER_TEXT (str) –

  • STYLE_USAGE (str) –

  • STYLE_USAGE_COMMAND (str) –

  • STYLE_DEPRECATED (str) –

  • STYLE_HELPTEXT_FIRST_LINE (str) –

  • STYLE_HELPTEXT (str) –

  • STYLE_OPTION_HELP (str) –

  • STYLE_OPTION_DEFAULT (str) –

  • STYLE_OPTION_ENVVAR (str) –

  • STYLE_REQUIRED_SHORT (str) –

  • STYLE_REQUIRED_LONG (str) –

  • STYLE_OPTIONS_PANEL_BORDER (str) –

  • ALIGN_OPTIONS_PANEL (str) –

  • STYLE_OPTIONS_TABLE_SHOW_LINES (bool) –

  • STYLE_OPTIONS_TABLE_LEADING (int) –

  • STYLE_OPTIONS_TABLE_PAD_EDGE (bool) –

  • STYLE_OPTIONS_TABLE_PADDING (Tuple[int, int]) –

  • STYLE_OPTIONS_TABLE_SHOW_EDGE (bool) –

  • STYLE_OPTIONS_TABLE_BOX (str) –

  • STYLE_OPTIONS_TABLE_ROW_STYLES (List[str] | None) –

  • STYLE_OPTIONS_TABLE_HEADER_STYLE (str) –

  • STYLE_OPTIONS_TABLE_BORDER_STYLE (str | None) –

  • STYLE_COMMANDS_PANEL_BORDER (str) –

  • ALIGN_COMMANDS_PANEL (str) –

  • STYLE_COMMANDS_TABLE_SHOW_LINES (bool) –

  • STYLE_COMMANDS_TABLE_LEADING (int) –

  • STYLE_COMMANDS_TABLE_PAD_EDGE (bool) –

  • STYLE_COMMANDS_TABLE_PADDING (Tuple[int, int]) –

  • STYLE_COMMANDS_TABLE_BOX (str) –

  • STYLE_COMMANDS_TABLE_ROW_STYLES (List[str] | None) –

  • STYLE_COMMANDS_TABLE_BORDER_STYLE (List[str] | None) –

  • STYLE_ERRORS_PANEL_BORDER (str) –

  • ALIGN_ERRORS_PANEL (str) –

  • STYLE_ERRORS_SUGGESTION (str) –

  • STYLE_ABORTED (str) –

  • MAX_WIDTH (int | None) –

  • COLOR_SYSTEM (Literal['auto', 'standard', '256', 'truecolor', 'windows'] | None) –

  • FORCE_TERMINAL (bool | None) –

  • HEADER_TEXT (str | None) –

  • HEADER_LOGO (str | None) –

  • FOOTER_TEXT (str | None) –

  • DEPRECATED_STRING (str) –

  • DEFAULT_STRING (str) –

  • ENVVAR_STRING (str) –

  • REQUIRED_SHORT_STRING (str) –

  • REQUIRED_LONG_STRING (str) –

  • RANGE_STRING (str) –

  • APPEND_METAVARS_HELP_STRING (str) –

  • ARGUMENTS_PANEL_TITLE (str) –

  • OPTIONS_PANEL_TITLE (str) –

  • COMMANDS_PANEL_TITLE (str) –

  • ERRORS_PANEL_TITLE (str) –

  • ERRORS_SUGGESTION (str | None) –

  • ERRORS_EPILOGUE (str | None) –

  • ABORTED_TEXT (str) –

  • SHOW_ARGUMENTS (bool) –

  • SHOW_METAVARS_COLUMN (bool) –

  • APPEND_METAVARS_HELP (bool) –

  • APPEND_METAVARS_REQUIRED (bool) –

  • GROUP_ARGUMENTS_OPTIONS (bool) –

  • OPTION_ENVVAR_FIRST (bool) –

  • USE_RST (bool) –

  • SHOW_RST_ERRORS (bool) –

  • USE_MARKDOWN (bool) –

  • USE_MARKDOWN_EMOJI (bool) –

  • USE_RICH_MARKUP (bool) –

  • CODE_THEME (str) –

  • USE_CLICK_SHORT_HELP (bool) –

  • VERSION_INFO (bool) –

  • VERBOSE_OPTION (bool) –

  • BG_PROCESS_OPTION (bool) –

  • files (List[str] | str | None) –

  • sections (List[str] | str | None) –

  • eval_env (bool | None) –

  • allow_empty (bool | None) –

  • init_from_default_cache (bool) –

ABORTED_TEXT: str
ALIGN_COMMANDS_PANEL: str
ALIGN_ERRORS_PANEL: str
ALIGN_OPTIONS_PANEL: str
APPEND_METAVARS_HELP: bool
APPEND_METAVARS_HELP_STRING: str
APPEND_METAVARS_REQUIRED: bool
ARGUMENTS_PANEL_TITLE: str
BG_PROCESS_OPTION: bool
CODE_THEME: str
COLOR_SYSTEM: Literal['auto', 'standard', '256', 'truecolor', 'windows'] | None
COMMANDS_PANEL_TITLE: str
COMMAND_GROUPS: Dict[str, List[Dict[str, str | List[str]]]]
CONTEXT_SETTINGS: Dict[str, List[Dict[str, str | List[str]]]]
DEFAULT_STRING: str
DEPRECATED_STRING: str
ENVVAR_STRING: str
ERRORS_EPILOGUE: str | None
ERRORS_PANEL_TITLE: str
ERRORS_SUGGESTION: str | None
FOOTER_TEXT: str | None
FORCE_TERMINAL: bool | None
GLOBAL_OPTIONS: List[GlobalOption]
GROUP_ARGUMENTS_OPTIONS: bool
HEADER_TEXT: str | None
MAX_WIDTH: int | None
OPTIONS_PANEL_TITLE: str
OPTION_ENVVAR_FIRST: bool
OPTION_GROUPS: Dict[str, List[Dict[str, str | List[str]]]]
RANGE_STRING: str
REQUIRED_LONG_STRING: str
REQUIRED_SHORT_STRING: str
SHOW_ARGUMENTS: bool
SHOW_METAVARS_COLUMN: bool
SHOW_RST_ERRORS: bool
STYLE_ABORTED: str
STYLE_ARGUMENT: str
STYLE_COMMANDS_PANEL_BORDER: str
STYLE_COMMANDS_TABLE_BORDER_STYLE: List[str] | None
STYLE_COMMANDS_TABLE_BOX: str
STYLE_COMMANDS_TABLE_LEADING: int
STYLE_COMMANDS_TABLE_PADDING: Tuple[int, int]
STYLE_COMMANDS_TABLE_PAD_EDGE: bool
STYLE_COMMANDS_TABLE_ROW_STYLES: List[str] | None
STYLE_COMMANDS_TABLE_SHOW_LINES: bool
STYLE_DEPRECATED: str
STYLE_ERRORS_PANEL_BORDER: str
STYLE_ERRORS_SUGGESTION: str
STYLE_HEADER_TEXT: str
STYLE_HELPTEXT: str
STYLE_HELPTEXT_FIRST_LINE: str
STYLE_METAVAR: str
STYLE_METAVAR_APPEND: str
STYLE_METAVAR_SEPARATOR: str
STYLE_OPTION: str
STYLE_OPTIONS_PANEL_BORDER: str
STYLE_OPTIONS_TABLE_BORDER_STYLE: str | None
STYLE_OPTIONS_TABLE_BOX: str
STYLE_OPTIONS_TABLE_HEADER_STYLE: str
STYLE_OPTIONS_TABLE_LEADING: int
STYLE_OPTIONS_TABLE_PADDING: Tuple[int, int]
STYLE_OPTIONS_TABLE_PAD_EDGE: bool
STYLE_OPTIONS_TABLE_ROW_STYLES: List[str] | None
STYLE_OPTIONS_TABLE_SHOW_EDGE: bool
STYLE_OPTIONS_TABLE_SHOW_LINES: bool
STYLE_OPTION_DEFAULT: str
STYLE_OPTION_ENVVAR: str
STYLE_OPTION_HELP: str
STYLE_REQUIRED_LONG: str
STYLE_REQUIRED_SHORT: str
STYLE_SWITCH: str
STYLE_USAGE: str
STYLE_USAGE_COMMAND: str
USE_CLICK_SHORT_HELP: bool
USE_MARKDOWN: bool
USE_MARKDOWN_EMOJI: bool
USE_RICH_MARKUP: bool
USE_RST: bool
VERBOSE_LOGGER: List[str]
VERBOSE_OPTION: bool
VERSION_INFO: bool
classmethod check_kwargs(**kwargs)

Check dataclass types.

Rückgabetyp:

Dict[str, Any]

static from_dict(*args, config_dict=None, **kwargs)
from_file(*, config_dict=None, **kwargs)
static from_ini(*args, **kwargs)
static from_yaml(*args, loader=<class 'yaml.loader.SafeLoader'>, **kwargs)
Parameter:

loader (Type[SafeLoader] | Type[UnsafeLoader]) –

classmethod keys()
to_dict()

Method to convert Dataclass with slots to dict.

Rückgabetyp:

dict

to_ini(out_cfg=None)

Method to write an instance of the main config class of the module into an ini file.

Parameter:

out_cfg (str | None) –

Rückgabetyp:

bytearray | None

to_tuple()

Method to convert Dataclass with slots to dict.

Rückgabetyp:

Any

to_yaml(*args, out_cfg=None, **kwargs)

Method to write an instance of the main config class of the module into a yaml file.

Parameter:

out_cfg (str | None) –

Rückgabetyp:

bytearray | None

update(new, merge_lists=False)
classmethod validate_kwargs(force=True, **kwargs)

Validate dataclass (includes type checks + validators).

class cornflakes.decorator.click.rich.RichGroup(*args, pass_context=None, config=None, **kwargs)[Quellcode]

Bases: Group

Richly formatted click Group.

Inherits click.Group and overrides help and error methods to print richly formatted output.

Parameter:
  • pass_context (bool | None) –

  • config (RichConfig) –

add_command(cmd, name=None)[Quellcode]

Registers another Command with this group.

If the name is not provided, the name of the command is used.

Parameter:
  • cmd (Command | RichCommand | Group | Any) –

  • name (str | None) –

Rückgabetyp:

None

callback()[Quellcode]

Callback method with is wrapped over the command group.

command(name, cmd=None)

Decorator to register a RichCommand with this group.

Parameter:
  • name (str | None) –

  • cmd (BaseCommand | Command | RichCommand | None) –

command_class

alias of RichCommand

commands: Dict[str, Command | RichCommand]

The registered subcommands by their exported names.

config: RichConfig
context_settings: dict

an optional dictionary with defaults passed to the context.

format_help(ctx, formatter)[Quellcode]

Format function of RichGroup.

Parameter:
  • ctx (Context) –

  • formatter (HelpFormatter) –

Rückgabetyp:

None

group(name, cmd=None)

Decorator to register a RichGroup with this group.

Parameter:
  • name (str | None) –

  • cmd (Group | RichGroup | None) –

group_class

alias of type

main(*args, standalone_mode=True, **kwargs)[Quellcode]

Main function of RichGroup.

Parameter:

standalone_mode (bool) –

Rückgabetyp:

Any

name = ''

the name the command thinks it has. Upon registering a command on a Group the group will default the command name with this information. You should instead use the Context's info_name attribute.

params: List[Parameter]

the list of parameters for this command in the order they should show up in the help page and execute. Eager parameters will automatically be handled before non eager ones.

pass_context: bool | None = False
cornflakes.decorator.click.rich.argument(*args, cls=<class 'cornflakes.decorator.click.rich._rich_argument.RichArg'>, **kwargs)[Quellcode]

Command decorator function.

Defines the command() function so that it uses the RichCommand class by default.

Rückgabetyp:

Callable[[…], Argument | RichArg]

cornflakes.decorator.click.rich.command(*args, cls=<class 'cornflakes.decorator.click.rich._rich_command.RichCommand'>, **kwargs)[Quellcode]

Command decorator function.

Defines the command() function so that it uses the RichCommand class by default.

Rückgabetyp:

Callable[[Callable[[…], Any] | Command | Group | RichCommand | RichGroup], RichCommand]

cornflakes.decorator.click.rich.group(*args, cls=<class 'cornflakes.decorator.click.rich._rich_group.RichGroup'>, **kwargs)[Quellcode]

Group decorator function.

Defines the group() function so that it uses the RichGroup class by default.

Rückgabetyp:

Callable[[Callable[[…], Any] | RichGroup], RichGroup]

cornflakes.decorator.click.rich.group_command(self, name, cmd=None)[Quellcode]

Decorator to register a RichCommand with this group.

Parameter:
  • name (str | None) –

  • cmd (BaseCommand | Command | RichCommand | None) –

cornflakes.decorator.click.rich.group_group(self, name, cmd=None)[Quellcode]

Decorator to register a RichGroup with this group.

Parameter:
  • name (str | None) –

  • cmd (Group | RichGroup | None) –

cornflakes.decorator.click.rich.option(*args, option_group='', **kwargs)[Quellcode]

Command decorator function.

Defines the command() function so that it uses the RichCommand class by default.

Rückgabetyp:

Callable[[…], Argument | RichArg]