Debug setting to print the args sent to do_xxx #1574
Unanswered
celephicus
asked this question in
Q&A
Replies: 1 comment 1 reply
-
|
@celephicus I'm glad you're finding When you say "namespace object", do you mean an If you mean the import argparse
from cmd2 import Statement
def do_foo(self, args: argparse.Namespace) -> None:
if self.debug_args:
statement: Statement = args.cmd2_statement.get()
self.poutput(f"Args: {statement}")That code will print the arguments passed to the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm liking cmd2, it does lots of work making things easy for me to concentrate on the code that actually does stuff.
I'm missing something that I've found useful: the ability to print the args namespace object that the do_xxx() functions use. I have been pasting the code in each command function, e.g:
def do_foo(self, args):
if self.debug_args:
self.poutput(f"Args: {str(data)}")
else:
......
Since the parsing is handled by decorators on the command function, not by the cmd2 framework, it looks like I need another decorator for the command function. But I've had no success writing one, can someone show me the way?
Beta Was this translation helpful? Give feedback.
All reactions