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

Getting command by name #202

Open
finger563 opened this issue May 5, 2023 · 1 comment
Open

Getting command by name #202

finger563 opened this issue May 5, 2023 · 1 comment

Comments

@finger563
Copy link

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.

@daniele77
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants