jade.utils.custom_click_options.CustomOptions¶
- class jade.utils.custom_click_options.CustomOptions(*args, **kwargs)[source]¶
Bases:
OptionCustom option class extending base click option
Methods
add_to_parser(parser, ctx)consume_value(ctx, opts)For
Option, the value can be collected from an interactive prompt if the option is a flag that needs a value (and thepromptproperty is set).get_default(ctx[, call])Return the default value for this option.
get_error_hint(ctx)Get a stringified version of the param for use in error messages to indicate which param caused the error.
get_help_extra(ctx)get_help_record(ctx)get_usage_pieces(ctx)handle_custom_options(opts)Handles custom options that have been created
handle_parse_result(ctx, opts, args)Process the value produced by the parser from user input.
make_metavar(ctx)process_value(ctx, value)Process the value of this parameter:
prompt_for_value(ctx)This is an alternative flow that can be activated in the full value processing if a value does not exist.
resolve_envvar_value(ctx)Optionresolves its environment variable the same way asParameter.resolve_envvar_value(), but it also supportsContext.auto_envvar_prefix. If we could not find an environment from theenvvarproperty, we fallback onContext.auto_envvar_prefixto build dynamiccaly the environment variable name using the :python:`{ctx.auto_envvar_prefix}_{self.name.upper()}` template.shell_complete(ctx, incomplete)Return a list of completions for the incomplete value.
type_cast_value(ctx, value)Convert and validate a value against the parameter's
type,multiple, andnargs.value_from_envvar(ctx)For
Option, this method processes the raw environment variable string the same way asParameter.value_from_envvar()does.value_is_missing(value)A value is considered missing if:
Attributes
Returns the human readable name of this parameter.
param_type_name- get_default(ctx: Context, call: bool = True) Any | Callable[[], Any] | None¶
Return the default value for this option.
For non-boolean flag options,
default=Trueis treated as a sentinel meaning “activate this flag by default” and is resolved toflag_value. For example, with--upper/--lowerfeature switches whereflag_value="upper"anddefault=True, the default resolves to"upper".Caution
This substitution only applies to non-boolean flags (
is_bool_flagisFalse). For boolean flags,Trueis a legitimate Python value anddefault=Trueis returned as-is.Changed in version 8.3.3:
default=Trueis no longer substituted withflag_valuefor boolean flags, fixing negative boolean flags likeflag_value=False, default=True.
- get_error_hint(ctx: Context | None) str¶
Get a stringified version of the param for use in error messages to indicate which param caused the error.
Changed in version 8.4.0:
ctxcan beNone.
- property human_readable_name: str¶
Returns the human readable name of this parameter. This is the same as the name for options, but the metavar for arguments.
- prompt_for_value(ctx: Context) Any¶
This is an alternative flow that can be activated in the full value processing if a value does not exist. It will prompt the user until a valid value exists and then returns the processed value as result.
- shell_complete(ctx: Context, incomplete: str) list[CompletionItem]¶
Return a list of completions for the incomplete value. If a
shell_completefunction was given during init, it is used. Otherwise, thetypeshell_complete()function is used.- Parameters:
ctx – Invocation context for this command.
incomplete – Value being completed. May be empty.
Added in version 8.0.
- to_info_dict() dict[str, Any]¶
Changed in version 8.3.0: Returns
Nonefor theflag_valueif it was not set.
- type_cast_value(ctx: Context, value: Any) Any¶
Convert and validate a value against the parameter’s
type,multiple, andnargs.