MWArgument

class lsst.daf.butler.cli.utils.MWArgument(param_decls: Sequence[str], required: bool | None = None, **attrs: Any)

Bases: Argument

Overrides click.Argument with desired behaviors.

Attributes Summary

human_readable_name

Returns the human readable name of this parameter.

param_type_name

Methods Summary

add_to_parser(parser, ctx)

consume_value(ctx, opts)

get_default(ctx[, call])

Get the default for the parameter.

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_record(ctx)

get_usage_pieces(ctx)

handle_parse_result(ctx, opts, args)

make_metavar()

Overrides click.Option.make_metavar.

process_value(ctx, value)

resolve_envvar_value(ctx)

shell_complete(ctx, incomplete)

Return a list of completions for the incomplete value.

to_info_dict()

Gather information that could be useful for a tool generating user-facing documentation.

type_cast_value(ctx, value)

Convert and validate a value against the option's type, multiple, and nargs.

value_from_envvar(ctx)

value_is_missing(value)

Attributes Documentation

human_readable_name
param_type_name = 'argument'

Methods Documentation

add_to_parser(parser: OptionParser, ctx: Context) None
consume_value(ctx: Context, opts: Mapping[str, Any]) Tuple[Any, ParameterSource]
get_default(ctx: Context, call: bool = True) Any | Callable[[], Any] | None

Get the default for the parameter. Tries Context.lookup_default() first, then the local default.

Parameters:
  • ctx – Current context.

  • call – If the default is a callable, call it. Disable to return the callable instead.

Changed in version 8.0.2: Type casting is no longer performed when getting a default.

Changed in version 8.0.1: Type casting can fail in resilient parsing mode. Invalid defaults will not prevent showing help text.

Changed in version 8.0: Looks at ctx.default_map first.

Changed in version 8.0: Added the call parameter.

get_error_hint(ctx: Context) str

Get a stringified version of the param for use in error messages to indicate which param caused the error.

get_help_record(ctx: Context) Tuple[str, str] | None
get_usage_pieces(ctx: Context) List[str]
handle_parse_result(ctx: Context, opts: Mapping[str, Any], args: List[str]) Tuple[Any, List[str]]
make_metavar() str

Overrides click.Option.make_metavar. Makes the metavar for the help menu. Always adds a space and an elipsis (’ …’) after the metavar name if the option accepts multiple inputs.

By default click adds an elipsis without a space between the metavar and the elipsis, but we prefer a space between.

Returns:
metavarstr

The metavar value.

process_value(ctx: Context, value: Any) Any
resolve_envvar_value(ctx: Context) str | None
shell_complete(ctx: Context, incomplete: str) List[CompletionItem]

Return a list of completions for the incomplete value. If a shell_complete function was given during init, it is used. Otherwise, the type shell_complete() function is used.

Parameters:
  • ctx – Invocation context for this command.

  • incomplete – Value being completed. May be empty.

New in version 8.0.

to_info_dict() Dict[str, Any]

Gather information that could be useful for a tool generating user-facing documentation.

Use click.Context.to_info_dict() to traverse the entire CLI structure.

New in version 8.0.

type_cast_value(ctx: Context, value: Any) Any

Convert and validate a value against the option’s type, multiple, and nargs.

value_from_envvar(ctx: Context) Any | None
value_is_missing(value: Any) bool