mlsimkit.common.cli.BaseCommand

class mlsimkit.common.cli.BaseCommand(name: str | None, context_settings: MutableMapping[str, Any] | None = None, callback: Callable[[...], Any] | None = None, params: list[Parameter] | None = None, help: str | None = None, epilog: str | None = None, short_help: str | None = None, options_metavar: str | None = '[OPTIONS]', add_help_option: bool = True, no_args_is_help: bool = False, hidden: bool = False, deprecated: bool | str = False)

A Click command that handles instantiating Pydantic models from flattened CLI params.

This class extends the click.Command class and overrides the format_options() and invoke() methods to handle instantiating Pydantic models from the command-line parameters.

format_options(ctx, formatter)

Format the command options for display.

invoke(ctx)

Invoke the command and instantiate Pydantic models from the parameters.

__init__(name: str | None, context_settings: MutableMapping[str, Any] | None = None, callback: Callable[[...], Any] | None = None, params: list[Parameter] | None = None, help: str | None = None, epilog: str | None = None, short_help: str | None = None, options_metavar: str | None = '[OPTIONS]', add_help_option: bool = True, no_args_is_help: bool = False, hidden: bool = False, deprecated: bool | str = False) None

Methods

__init__(name[, context_settings, callback, ...])

collect_usage_pieces(ctx)

Returns all the pieces that go into the usage line and returns it as a list of strings.

format_epilog(ctx, formatter)

Writes the epilog into the formatter if it exists.

format_help(ctx, formatter)

Writes the help into the formatter if it exists.

format_help_text(ctx, formatter)

Writes the help text to the formatter if it exists.

format_options(ctx, formatter)

Writes all the options into the formatter if they exist.

format_usage(ctx, formatter)

Writes the usage line into the formatter.

get_help(ctx)

Formats the help into a string and returns it.

get_help_option(ctx)

Returns the help option object.

get_help_option_names(ctx)

Returns the names for the help option.

get_params(ctx)

get_short_help_str([limit])

Gets short help for the command or makes it by shortening the long help string.

get_usage(ctx)

Formats the usage line into a string and returns it.

invoke(ctx)

Given a context, this invokes the attached callback (if it exists) in the right way.

main([args, prog_name, complete_var, ...])

This is the way to invoke a script with all the bells and whistles as a command line application.

make_context(info_name, args[, parent])

This function when given an info name and arguments will kick off the parsing and create a new Context.

make_parser(ctx)

Creates the underlying option parser for this command.

parse_args(ctx, args)

shell_complete(ctx, incomplete)

Return a list of completions for the incomplete value.

to_info_dict(ctx)

Attributes

allow_extra_args

the default for the Context.allow_extra_args flag.

allow_interspersed_args

the default for the Context.allow_interspersed_args flag.

ignore_unknown_options

the default for the Context.ignore_unknown_options flag.

name

the name the command thinks it has.

context_settings

an optional dictionary with defaults passed to the context.

callback

the callback to execute when the command fires.

params

the list of parameters for this command in the order they should show up in the help page and execute.

format_options(ctx, formatter)

Writes all the options into the formatter if they exist.

invoke(ctx)

Given a context, this invokes the attached callback (if it exists) in the right way.

parse_args(ctx: Context, args: list[str]) list[str]