-
Notifications
You must be signed in to change notification settings - Fork 128
Command history missing for default commands #1387
-
Due to some requirement, i have made a default command by overriding the default() function as shown below:
# Default command to be 'run'
def default(self, stmt):
self.do_run(stmt.raw)
Because of this, most of the time users would be invoking 'run' command directly with arguments instead of calling 'run ':
(cmd2) <args>
instead of
(cmd2) run <args>
The run command doesn't have argparse options so it works seamlessly.
But unfortunately, these commands don't show up in the history when i restart my application & check using 'history' command or by Up & down arrows.
May i know if this is supported?
Beta Was this translation helpful? Give feedback.
All reactions
Call one of the following:
self.onecmd_plus_hooks(f"run {stmt.raw}")self.onecmd(f"run {stmt.raw}")
Replies: 1 comment 2 replies
-
Call one of the following:
self.onecmd_plus_hooks(f"run {stmt.raw}")self.onecmd(f"run {stmt.raw}")
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks it works.
Beta Was this translation helpful? Give feedback.
All reactions
-
It seems we run into issues when we declare macros for default commands; The macro doesn't get expanded because stmt.raw contains the macro version & not the expanded one which sits inside stmt.args
So the solution looks like:
self.onecmd(f"run {stmt.command} {stmt.args}")
Am i right Kevin?
Beta Was this translation helpful? Give feedback.