cli icon indicating copy to clipboard operation
cli copied to clipboard

Getting command by name

Open finger563 opened this issue 2 years ago • 1 comments

I don't see an API for getting a command by name, but I'd like to be able to disable the exit action on menus in certain contexts. Based on a quick read through the API, it seems like if I could get a reference to the descriptor for the pre-populated exit action, I could then disable it.

finger563 avatar May 05 '23 17:05 finger563

Unfortunately, it's not possible to add a search of a command by name, because the commands names are not unique. In particular:

  • different commands can have the same name but different argument number
  • you can have the same command name in different menus

For user-defined commands, you get the CmdHandler when inserting it in a menu. The problem is with the two default global commands "exit" and "help". They're "global" meaning that these commands are visible from every submenu. These are created internally by the library and their Cmdhandler is not exported.

To disable the global commands, the library should expose the CmdHandler of these commands. This feature is not so simple to implement, because the commands are added at the session level, and since we may have many sessions (e.g. a local session, multiple remote sessions, etc.) they are duplicated.

daniele77 avatar Jun 29 '23 13:06 daniele77