Skip to content

Refactor class ParameterFormatters and docstrings #127

@ckunki

Description

@ckunki

(1) Update the docstring for argument formatters of function select_std_options

Proposal

    formatters:
        A dictionary, with each key being a source CLI parameter,
        see docstring of class ParamUpdater.

        Each value is an instance of ParamUpdater representing a single or
        multiple destination parameters to be updated based on the source
        parameter's value. A destination parameter can be updated multiple
        times, if it depends on multiple source parameters.

(2) docstring and implementation of class ParameterFormatters are hard to understand.

Here is a proposal for an updated docstring

    Dynamic update for customized CLI parameters.

    Example: A specialized variant of the CLI may want to provide a custom URL
    "http://prefix/{version}/suffix" depending on CLI parameter "version".  If
    the user specifies version "1.2.3", then the default value for the URL
    should be updated to "http://prefix/1.2.3/suffix".

    The URL parameter in this example is called a _destination_ CLI parameter
    while the version is called _source_.

    A destination parameter can depend on a single or multiple source
    parameters.  In the previous example the URL could, for instance, also
    include a username: "http://prefix/{version}/{user}/suffix".

    The Click API allows updating customized parameters only in a callback
    function.  There is no way to inject them directly into the CLI, see
    https://click.palletsprojects.com/en/stable/api/#click.Command.callback.

    The current implementation updates the destination parameter only if the
    value of the source parameter is not ``None``.

Metadata

Metadata

Assignees

Labels

refactoringCode improvement without behavior change

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions