Skip to content

#127: Refactored class ParameterFormatters and docstrings#128

Open
ckunki wants to merge 13 commits intomainfrom
refactoring/127-Refactored_class_ParameterFormatters_and_docstrings
Open

#127: Refactored class ParameterFormatters and docstrings#128
ckunki wants to merge 13 commits intomainfrom
refactoring/127-Refactored_class_ParameterFormatters_and_docstrings

Conversation

@ckunki
Copy link
Contributor

@ckunki ckunki commented Feb 4, 2026

Closes #127

ctx.params[parameter_name] = param_formatter.format(**kwargs) # type: ignore
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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A callback is the function click is calling for a command. This is nothing special. It is the same as

@command
def my_command(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the doc string. Please review again.

Dynamic formatting for customized Click CLI parameters.

The idea is that some of the cli parameters can be programmatically customized based
on values of other parameters and externally supplied formatters. For example a specialized
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, the new description is more cryptic than the original one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the doc string. Please review again.


return source.value

def set_formatter(self, param_name: str, default_value: str) -> None:
Copy link
Collaborator

@tkilias tkilias Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def set_formatter(self, param_name: str, default_value: str) -> None:
def set_formatter(self, destination_parameter: str, format_pattern: str) -> None:

we can't rename, because this would break the public interface, for this reason we add this information to the docstrings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor class ParameterFormatters and docstrings

2 participants