-
Notifications
You must be signed in to change notification settings - Fork 58
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
[bug] support trogon with --tui
flag?
#34
Comments
You mean your script only has one command? import click
from trogon import Trogon
def open_tui(ctx, param, value):
if not value or ctx.resilient_parsing:
return
Trogon(ctx.command, app_name=ctx.info_name, click_context=ctx).run()
ctx.exit()
@click.option(
"--tui",
help="Open Textual TUI.",
is_flag=True,
callback=open_tui,
expose_value=False,
is_eager=True,
)
@click.command()
def acquire():
click.echo("Hello world")
if __name__ == "__main__":
acquire() |
Thanks @slafs this works well for me! I edited your def open_tui(ctx, param, value):
if not value or ctx.resilient_parsing:
return
# remove --tui from context
del ctx.command.params[0]
Trogon(ctx.command, app_name=ctx.info_name, click_context=ctx).run()
ctx.exit() |
actually, I spoke too soon. This does not work- when launching from the TUI, Trogon still tries putting the command name into the command- command crafted in TUI:
command ran:
|
Ah, interesting. Now that is a bug, I think. Especially that there's a difference between the TUI command and what's actually being run. It seems like Trogon assumes that there needs to be a command to call. After a brief look at the code there seems to be some sort of support for Lines 262 to 265 in 2059c51
@mileslucas if I were you, I'd change the title of this issue from |
--tui
flag?--tui
flag?
I also would really like this feature. I have several cli apps that are built with |
I had a similar question, not sure if it's useful but I asked in the discord: https://discord.com/channels/1026214085173461072/1033754296224841768/1115571327370264628 Basically, I had to replace (Now I have new issue to look at because I suck up all remaining args with |
So far I've really enjoyed using trogon, it's integrated really smoothly into the couple of click CLIs I'm preparing for deployment on a telescope control module. Something I don't vibe with, though, is forcing the use of groups for the scripts. Something I've just been writing is an
acquire
scripts with a bunch of options that I like having the TUI for. But having to rework my CLI to look likeacquire int <args>
or something like that to allow theacquire tui
group is something I dislike.What I think I would prefer is a
--tui
flag that has eager execution. I think this could be added to the api in a backwards-compatible way with a keyword argument in the decorator@tui(eager_option=True)
and that way I can call my script with
and launch into the TUI, whereas
would run the command as normal (no forced group)
The text was updated successfully, but these errors were encountered: