-
Notifications
You must be signed in to change notification settings - Fork 2
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
History is broken for non-top level #9
Comments
We dramatically changed how history works for newer versions of To be honest, this plugin isn't very well maintained or a priority for the core See the section in the docs on Disabling Comamnds and the help_categories.py example for more info. |
I see. Thank you for the reply. I had a look at disable and enable commands, and it doesn't fit my use case at all I'm afraid. I mean, I could use it, but it feels like a giant hack. It's for some internal test tooling at work. Currently we have an application with about 1100 commands spread across 50 modules. The modules are found on the top level, and the commands are the second level. Due to how this tooling works, and the desired use of it, it's not possible to run these modules separately. You really want to start up the application with all modules for all available systems loaded, and then switch between them depending on what you want to test/verify. I'm fully aware that this is quite outside of what cmd2 is meant for, but so far it works quite well. I already saw that there wasn't much activity in terms of |
99% of developers using @kmvanbrunt or @anselor Can either of you comment further? |
@AHSauge The submenu module has never been stable. It's poorly designed and that's why we moved it out of the main code. Have you considered using argparse subcommands as a solution? Each of your 50 modules would be a top level command (parser) and all module-specific commands would be subcommands (subparsers) of them. |
You can also build 2 levels of argparse parsers. The upper layer can load your plugin modules and auto-complete them as if they're a sub-command. Then consume all remaining arguments and then pass them down to the next layer's argparser. |
See the attached example where I've tried to get history to work for all three levels in the example provided in the repository.
My interaction is as follows:
We can see that from the top level I have executed 'second say asd' and on the second level I have excuted 'third say qwe'
When restarting the script, I can correctly press arrow up to find both 'second' and 'second say asd'. However, if I go into the second level I only get gibberish like '(X^D', 'q^FX^G' and 'q^B)�q^C}q^D(X '
Here is a zip file of the script and the history file after the first execution
example.zip
The text was updated successfully, but these errors were encountered: