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.
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:
The
runserver
sub-command actually runs with port 5000 because of thedefault_map
. But trogon prefills the textbox in the TUI with port 8000, which is wrong.