click_extra.show_params module

        classDiagram
  ExtraOption <|-- ShowParamsOption
  ParamStructure <|-- ShowParamsOption
    

The --params option, which prints a table of every parameter of a CLI.

The table shows each parameter’s value and where that value comes from: the command line, an environment variable, a configuration file or a default.

click_extra.show_params.param_config_source(root_ctx, keys)[source]

Return the configuration file supplying a parameter’s default_map value.

keys is the parameter’s fully-qualified path, root command name first and parameter name last, as yielded by walk_command_params(). A local file is returned as a Path, a remote one as its URL, a str. Returns None when no configuration file was loaded, when the parameter is absent from every loaded layer, or when the context carries no layered default_map at all.

The walk mirrors how Click resolves default_map, so the attribution matches the value Click actually picks. The root context’s default_map is a ~collections.ChainMap whose first layers are the loaded files, in the order of CONF_SOURCES. A key resolves to the first layer holding it, in a subcommand section as at the root: the first layer holding the whole path of the parameter names the file.

Note

Lazy subcommands receive their section from the merged configuration document, injected into the front layer by _apply_config_to_parent_context(): those values are attributed to the highest-precedence file even when several files contributed to the merge.

Return type:

Path | str | None

click_extra.show_params.render_params_table(subject_ctx, *, default_columns=None)[source]

Introspect subject_ctx.command and print its parameter metadata table.

Walks the command and any nested subcommands, emitting one row per parameter. The table format and column selection are read from subject_ctx.meta (see TABLE_FORMAT and COLUMNS); when neither is set, a sibling --table-format / --columns option on the command is consulted, then the default_columns fallback, then the canonical order.

When subject_ctx.meta carries pre-parsed RAW_ARGS, the value and source columns are resolved by replaying those arguments against the command parser; otherwise they fall back to the parameter defaults.

This is the shared rendering core behind both print_params() (introspecting the live CLI) and the click-extra wrap --params path (introspecting a foreign target). The caller is responsible for exiting the context afterwards.

Important

Click does not keep the raw, pre-parsed arguments around, so values and their provenance cannot be read back directly. The workaround replays RAW_ARGS (captured on the context by Command/Group) through the command parser, calling consume_value() rather than handle_parse_result() so eager callbacks are not re-triggered.

Return type:

None

class click_extra.show_params.ShowParamsOption(param_decls=None, *, is_flag=True, expose_value=False, is_eager=True, help='Show all CLI parameters, their provenance, defaults and value, then exit.', **kwargs)[source]

Bases: ExtraOption, ParamStructure

A pre-configured option adding a --params option.

Between configuration files, default values and environment variables, it might be hard to guess under which set of parameters the CLI will be executed. This option prints information about the parameters that will be fed to the CLI.

Note

The flag is named --params, not --show-params. It names the view it prints, matching the neighbouring bare-noun informational flags (--help, --version, --man, --tree), none of which carry a show- verb prefix. The class and the @show_params_option decorator are named for what they do (show the parameters), while the flag and the parameter’s ID use the bare noun.

TABLE_HEADERS: ClassVar[tuple[ColumnSpec, ...]] = (ColumnSpec(id='id', label='ID', description='Fully-qualified parameter path (`cli.subcommand.param_name`) derived from the [`click.Command`](https://click.palletsprojects.com/en/stable/api/#click.Command) tree. Doubles as the key used to address the parameter from a configuration file, which also accepts the kebab-case spelling of the last segment.', max_width=None, optional=False, sortable=True), ColumnSpec(id='spec', label='Spec.', description='Option/argument specification string (like `-v, --verbose`) extracted from [`click.Parameter.get_help_record()`](https://click.palletsprojects.com/en/stable/api/#click.Parameter).', max_width=None, optional=False, sortable=True), ColumnSpec(id='help', label='Help', description="The parameter's own help text, as written by the CLI author. Opt-in: it is the only column carrying free-form prose, so it stays out of the default table and is selected by ID (`--columns id,spec,help`). Structured formats are its main audience: it turns a `--params` dump into a self-describing inventory a tool or an agent can read without also parsing the rendered `--help` screen.", max_width=None, optional=True, sortable=True), ColumnSpec(id='class', label='Class', description="Fully-qualified class of the parameter: a subclass of [`click.Option`](https://click.palletsprojects.com/en/stable/api/#click.Option), [`click.Argument`](https://click.palletsprojects.com/en/stable/api/#click.Argument), [`cloup.Option`](https://cloup.readthedocs.io/en/stable/autoapi/cloup/index.html#cloup.Option), or one of Click Extra's own wrappers ([`click_extra.parameters.Option`](#click_extra.parameters.Option), [`click_extra.parameters.Argument`](#click_extra.parameters.Argument), [`click_extra.parameters.ExtraOption`](#click_extra.parameters.ExtraOption)).", max_width=None, optional=False, sortable=True), ColumnSpec(id='param_type', label='Param type', description='Click value converter class: a subclass of [`click.ParamType`](https://click.palletsprojects.com/en/stable/api/#click.ParamType) like [`click.IntRange`](https://click.palletsprojects.com/en/stable/api/#click.IntRange), [`click.Choice`](https://click.palletsprojects.com/en/stable/api/#click.Choice), or a Click Extra type.', max_width=None, optional=False, sortable=True), ColumnSpec(id='python_type', label='Python type', description='Python built-in type the parsed value resolves to: [`str`](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), [`int`](https://docs.python.org/3/library/functions.html#int), [`float`](https://docs.python.org/3/library/functions.html#float), [`bool`](https://docs.python.org/3/library/functions.html#bool), or [`list`](https://docs.python.org/3/library/stdtypes.html#list). Computed by [`ParamStructure.get_param_type()`](#click_extra.param_tools.ParamStructure.get_param_type) from the Click `Param type`.', max_width=None, optional=False, sortable=True), ColumnSpec(id='hidden', label='Hidden', description="Reflects [`click.Option`'s `hidden`](https://click.palletsprojects.com/en/stable/api/#click.Option) constructor argument: the option is omitted from `--help` output. Empty for [`click.Argument`](https://click.palletsprojects.com/en/stable/api/#click.Argument), which does not support hiding.", max_width=None, optional=False, sortable=True), ColumnSpec(id='exposed', label='Exposed', description="Reflects [`click.Parameter`'s `expose_value`](https://click.palletsprojects.com/en/stable/api/#click.Parameter) constructor argument: whether the parsed value is forwarded to the command callback. Eager options like `--params` and `--help` typically run a callback and exit, so they are not exposed.", max_width=None, optional=False, sortable=True), ColumnSpec(id='allowed_in_conf', label='Allowed in conf?', description='Click Extra-specific: whether the parameter is reachable from a configuration file. Controlled by [`ParamStructure.excluded_params`](#click_extra.param_tools.ParamStructure.excluded_params) and [`included_params`](#click_extra.param_tools.ParamStructure.included_params). Empty when the CLI has no [`--config` option](config.md).', max_width=None, optional=False, sortable=True), ColumnSpec(id='envvars', label='Env. vars.', description="Environment variables read for this parameter: the explicit [`click.Parameter`'s `envvar`](https://click.palletsprojects.com/en/stable/api/#click.Parameter) plus the auto-resolved IDs documented in [Environment variables](envvar.md).", max_width=None, optional=False, sortable=True), ColumnSpec(id='default', label='Default', description='Default value returned by [`click.Parameter.get_default()`](https://click.palletsprojects.com/en/stable/api/#click.Parameter.get_default), rendered as its Python `repr()`.', max_width=None, optional=False, sortable=True), ColumnSpec(id='is_flag', label='Is flag', description="Reflects [`click.Option`'s `is_flag`](https://click.palletsprojects.com/en/stable/api/#click.Option): whether the option behaves as a flag (no value taken from the command line). Empty for [`click.Argument`](https://click.palletsprojects.com/en/stable/api/#click.Argument).", max_width=None, optional=False, sortable=True), ColumnSpec(id='flag_value', label='Flag value', description="Reflects [`click.Option`'s `flag_value`](https://click.palletsprojects.com/en/stable/api/#click.Option): the Python value substituted for the option when its flag is used. Defaults to `True` for boolean flags, can be any value for flag-value style options (like `@option('--upper', 'transform', flag_value='upper')`).", max_width=None, optional=False, sortable=True), ColumnSpec(id='is_bool_flag', label='Is bool flag', description='Reflects `click.Option.is_bool_flag` (set internally by Click when `flag_value` is `True` or `False`): the option is a *true* boolean flag, as opposed to a flag-value style option.', max_width=None, optional=False, sortable=True), ColumnSpec(id='multiple', label='Multiple', description="Reflects [`click.Parameter`'s `multiple`](https://click.palletsprojects.com/en/stable/api/#click.Parameter): the parameter can be repeated on the command line, collecting values into a tuple.", max_width=None, optional=False, sortable=True), ColumnSpec(id='nargs', label='Nargs', description="Reflects [`click.Parameter`'s `nargs`](https://click.palletsprojects.com/en/stable/api/#click.Parameter): the number of CLI tokens the parameter consumes. `1` is the default; `-1` denotes a variadic argument.", max_width=None, optional=False, sortable=True), ColumnSpec(id='prompt', label='Prompt', description="Reflects [`click.Option`'s `prompt`](https://click.palletsprojects.com/en/stable/api/#click.Option): the text shown to the user when the option is not provided on the command line. Empty when no prompt is configured.", max_width=None, optional=False, sortable=True), ColumnSpec(id='confirmation_prompt', label='Confirmation prompt', description="Reflects [`click.Option`'s `confirmation_prompt`](https://click.palletsprojects.com/en/stable/api/#click.Option): whether the user is asked to enter the value twice for confirmation.", max_width=None, optional=False, sortable=True), ColumnSpec(id='value', label='Value', description='Current value of the parameter at invocation time, computed by [`click.Parameter.consume_value()`](https://click.palletsprojects.com/en/stable/api/#click.Parameter) from the merged sources (CLI, environment, config file, default).', max_width=None, optional=False, sortable=True), ColumnSpec(id='source', label='Source', description='Provenance of the resolved value: a [`click.core.ParameterSource`](https://click.palletsprojects.com/en/stable/api/#click.core.ParameterSource) enum member such as `COMMANDLINE`, `ENVIRONMENT`, `DEFAULT_MAP`, or `DEFAULT`.', max_width=None, optional=False, sortable=True), ColumnSpec(id='config_file', label='Config file', description='The configuration file the effective value was loaded from, when `Source` reports `DEFAULT_MAP`. With [`cascade=True`](config-discovery.md#cascading-configuration-files) several files are layered and this column names the one that won the parameter; with a single loaded file, every config-sourced parameter names that file. Empty for every other source and when no configuration file was loaded. Drawn by default when the `--config` option cascades, and opt-in otherwise, like `help`: paths are wide and stay redundant with `Source` until several files can take part.', max_width=None, optional=True, sortable=True))

Rich column registry for the --params table.

Each entry is a click_extra.columns.ColumnSpec carrying the column’s stable id (used by --columns and as structured-format key), its display label, and a MyST/Markdown description consumed by the documentation’s auto-generated Available columns section. Iteration yields columns in canonical display order.

classmethod column_labels()[source]

Return just the display labels of TABLE_HEADERS (in order).

Return type:

tuple[str, ...]

classmethod column_ids()[source]

Return just the stable IDs of TABLE_HEADERS (in order).

Return type:

tuple[str, ...]

classmethod default_columns()[source]

Return the columns rendered when --columns asks for no projection.

Every column but the optional ones, which stay addressable by ID and out of the way until named.

Return type:

tuple[ColumnSpec, ...]

classmethod default_column_ids()[source]

Return the stable IDs of default_columns() (in order).

Return type:

tuple[str, ...]

classmethod default_column_labels()[source]

Return the display labels of default_columns() (in order).

Return type:

tuple[str, ...]

classmethod find_column(column_id)[source]

Return the ColumnSpec matching column_id.

Raises:

KeyError – if no column has this ID. Convert it into a click.UsageError before it reaches a user.

Return type:

ColumnSpec

classmethod render_doc_table()[source]

Render TABLE_HEADERS as a Markdown table for documentation.

Used by the show_params_columns_table MyST substitution in docs/conf.py to feed the Available columns section of docs/parameters.md: editing a description here automatically rebuilds the docs table on the next sphinx-build.

Return type:

str

excluded_params: frozenset[str]

Deactivates the blocking of any parameter.

included_params: frozenset[str] | None

No allowlist filter; show all parameters.

print_params(ctx, param, value)[source]

Introspect the current CLI and print its parameter metadata table.

Thin wrapper over render_params_table(), the shared rendering core also driving click-extra wrap --params for foreign CLIs. The live invocation context carries everything the core needs: the captured RAW_ARGS (attached by Command/Group) for value and source resolution, plus any sibling --table-format / --columns options.

Return type:

None