I am using the Cmd2 module in Python (version 1.0.2) to build a command-line interface (CLI).
After I run the program (so that I am inside my custom CLI), if I want debugging to be enabled so that it shows stack traces on errors, I have to manually run "set debug true" from the CLI.
What I want is a way to automatically set the "debug" flag to true every time the CLI is invoked. I know I can pass scripts to the CLI that include setting debug as the first step, but I want interactive sessions to also have this behavior.
Is there any way to change the default value for debug in Cmd2?
The
cmd2
docs about settings say (emphases mine):So, to enable the
debug
setting by default, you just have to set thedebug
attribute of yourcmd2.Cmd
object toTrue
. For example, if this is the app:you just have to do
Now, if I run the app from the command line,
debug
will be enabled by default.Full Python code:
Input:
Output: