@@ -59,6 +59,7 @@ def __init__(
5959 self ,
6060 cli : click .BaseCommand ,
6161 click_app_name : str ,
62+ command_name : str ,
6263 name : str | None = None ,
6364 id : str | None = None ,
6465 classes : str | None = None ,
@@ -69,6 +70,7 @@ def __init__(
6970 self .is_grouped_cli = isinstance (cli , click .Group )
7071 self .command_schemas = introspect_click_app (cli )
7172 self .click_app_name = click_app_name
73+ self .command_name = command_name
7274
7375 try :
7476 self .version = metadata .version (self .click_app_name )
@@ -78,7 +80,7 @@ def __init__(
7880 self .highlighter = ReprHighlighter ()
7981
8082 def compose (self ) -> ComposeResult :
81- tree = CommandTree ("Commands" , self .command_schemas )
83+ tree = CommandTree ("Commands" , self .command_schemas , self . command_name )
8284
8385 title_parts = [Text (self .click_app_name , style = "b" )]
8486 if self .version :
@@ -216,8 +218,9 @@ class Trogon(App):
216218 def __init__ (
217219 self ,
218220 cli : click .Group ,
219- app_name : str = None ,
220- click_context : click .Context = None ,
221+ app_name : str | None = None ,
222+ command_name : str = "tui" ,
223+ click_context : click .Context | None = None ,
221224 ) -> None :
222225 super ().__init__ ()
223226 self .cli = cli
@@ -228,9 +231,10 @@ def __init__(
228231 self .app_name = detect_run_string ()
229232 else :
230233 self .app_name = app_name
234+ self .command_name = command_name
231235
232236 def on_mount (self ):
233- self .push_screen (CommandBuilder (self .cli , self .app_name ))
237+ self .push_screen (CommandBuilder (self .cli , self .app_name , self . command_name ))
234238
235239 @on (Button .Pressed , "#home-exec-button" )
236240 def on_button_pressed (self ):
@@ -289,7 +293,7 @@ def tui(name: str | None = None, command: str = "tui", help: str = "Open Textual
289293 def decorator (app : click .Group | click .Command ):
290294 @click .pass_context
291295 def wrapped_tui (ctx , * args , ** kwargs ):
292- Trogon (app , app_name = name , click_context = ctx ).run ()
296+ Trogon (app , app_name = name , command_name = command , click_context = ctx ).run ()
293297
294298 if isinstance (app , click .Group ):
295299 app .command (name = command , help = help )(wrapped_tui )
0 commit comments