Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taking default_map as source of default values into account #54

Open
notniknot opened this issue Jul 22, 2023 · 0 comments
Open

Taking default_map as source of default values into account #54

notniknot opened this issue Jul 22, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@notniknot
Copy link

When I specify the default parameter in an option, trogon considers this value in the TUI. But when I pass a default_map as part of the context_settings (like shown in the click docs here and here) the option doesn't get prefilled.

This behaviour might be misleading because an existing default_map overwrites an options default value. Thus, the application actually runs with a different option value than trogon suggested.

Consider the following code:

import click
from trogon import tui


@tui(command="ui", help="Open terminal UI")
@click.group()
def cli():
    pass


@cli.command()
@click.option("--port", default=8000, show_default=True)
def runserver(port):
    click.echo(f"Serving on http://127.0.0.1:{port}/")


if __name__ == "__main__":
    cli(default_map={"runserver": {"port": 5000}})

The runserver sub-command actually runs with port 5000 because of the default_map. But trogon prefills the textbox in the TUI with port 8000, which is wrong.

@daneah daneah added the enhancement New feature or request label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants