Karana.KUtils.Kclick#

Classes and functions used to create a Kclick CLI application.

This module contains classes and functions used to create Kclick CLI applications. Kclick is a thin wrapper around the third-party, open-source click package, which is used to quickly generate high-quality CLI applications.

Attributes#

Classes#

KGroup

Thin wrapper around click.Group that simplifies command functions.

Functions#

error(err)

Print out error text in red.

cli(ctx, **kwargs)

Major click group.

test(ctx, **kwargs)

Kclick cli group callback.

runCli(→ tuple[click.core.Context, dict[str, Any]])

Run the Kclick cli group and return the parsed results.

Module Contents#

Karana.KUtils.Kclick.kclick_options#
Karana.KUtils.Kclick.output_type = ''#
Karana.KUtils.Kclick.cfg_file = ''#
Karana.KUtils.Kclick.error(err: str)[source]#

Print out error text in red.

class Karana.KUtils.Kclick.KGroup(name: str | None = None, commands: MutableMapping[str, Command] | Sequence[Command] | None = None, **attrs: Any)[source]#

Bases: click.Group

Thin wrapper around click.Group that simplifies command functions.

Command functions need only return the incoming kwargs. The logic used here will automatically update the kclick_options with said kwargs.

add_command(cmd: click.Command, name: str | None = None)[source]#

Thin wrapper around click.Group.add_command that simplfies command functions.

Command functions need only return the incoming kwargs. The logic used here will automatically update the kclick_options with said kwargs.

Karana.KUtils.Kclick.cli(ctx, **kwargs)[source]#

Major click group.

This is the main click group used for all Kclick CLI applications. Commands and options can be added to this group, and they will show up in your Kclick CLI application.

Karana.KUtils.Kclick.test(ctx, **kwargs)[source]#

Kclick cli group callback.

This callback merges all options from all commands.

Karana.KUtils.Kclick.runCli() tuple[click.core.Context, dict[str, Any]][source]#

Run the Kclick cli group and return the parsed results.

Run the Kclick cli group, which will parse the incoming CLI options. This is then merged into a single dictionary with all the final option values.

Returns:

A tuple where the first element is the click context object and the second is the CLI options.

Return type:

tuple[click.core.Context, dict[str, Any]]