How to use do_func
directly?
#1400
-
I am working on an application which provides a command that runs multiple commands, something like the following:
You might notice the
The However, now I would also like to expose the command to TCL and allow the user to execute TCL script. When I register a similar type of function, command with an optional positional argument, the TCL execution will fail with the same error. To make the error go away, in the TCL script will need to write |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Your code actually exposed a bug in ours. We aren't checking the length of TypeError('Expected arguments: cmd: cmd2.Cmd, statement: Union[Statement, str] Not found') Since command functions expect a Then you would decorate your function with something like: @allow_blank
@with_argparser(...)
def do_gen_geometry(self, args: argparse.Namespace):
.... |
Beta Was this translation helpful? Give feedback.
I wouldn't patch the
cmd2
code unless you're willing to re-patch it every time we put out a new release.It's easier to write your own decorator to do that.