You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
override / silence output on change of settable #1420
@gjvc This is an interesting and reasonable suggestion. I can see several potential ways to go about it, including at least all of the following:
Add -q/--quiet flag to the set command that suppresses default output from cmd2. This is easily done. It would require users to add the -q flag each time.
Add an optional boolean parameter to the cmd2.Cmd.__init__() method called something like silence_set which has a global effect of silencing the default cmd2 output from the set command. This is also relatively easy and has the benefit of not requiring users to enter anything each time.
You can override the do_set method of cmd2.Cmd in your application and modify accordingly. Also easy, but requires work on your end, not on the cmd2 end.
Which do you think would best meet your needs and would provide the best overall user experience?
@gjvc Would simply redirecting the output of that command to /dev/null be a reasonable option for you?
set package_path devel/mold/2.36 > /dev/null
2025-05-22T23:45:05.615 I t/b/s/shell.py:99 package_path='lang/python/3.10' ->'devel/mold/2.36'
The easiest option I see is for you to either just redirect to /dev/null or to override the do_set method in your class which inherits from cmd2.Cmd. If you want to override it, just make a copy of our code and delete the line with the poutput call outputting that output. Alternatively, you can change the poutput to a pfeedback and change the quiet setting in your app to default to True.
I don't like the option of adding a -q flag to the set command, it just doesn't feel right for that command. I also don't like the idea of adding another optional parameter to the __init__() method for cmd2.Cmd for this niche case.
If we had it to do over again, we would perhaps choose to use pfeedback instead of poutput to output that info as it isn't really essential, but doing it at this point would be a breaking change which would pretty much be guaranteed to break someone else's application.
Activity
tleonhardt commentedon May 23, 2025
@gjvc This is an interesting and reasonable suggestion. I can see several potential ways to go about it, including at least all of the following:
-q/--quietflag to thesetcommand that suppresses default output fromcmd2. This is easily done. It would require users to add the-qflag each time.cmd2.Cmd.__init__()method called something likesilence_setwhich has a global effect of silencing the defaultcmd2output from thesetcommand. This is also relatively easy and has the benefit of not requiring users to enter anything each time.do_setmethod ofcmd2.Cmdin your application and modify accordingly. Also easy, but requires work on your end, not on thecmd2end.Which do you think would best meet your needs and would provide the best overall user experience?
tleonhardt commentedon Jun 13, 2025
@gjvc Would simply redirecting the output of that command to
/dev/nullbe a reasonable option for you?The easiest option I see is for you to either just redirect to
/dev/nullor to override thedo_setmethod in your class which inherits fromcmd2.Cmd. If you want to override it, just make a copy of our code and delete the line with thepoutputcall outputting that output. Alternatively, you can change thepoutputto apfeedbackand change thequietsetting in your app to default toTrue.I don't like the option of adding a
-qflag to thesetcommand, it just doesn't feel right for that command. I also don't like the idea of adding another optional parameter to the__init__()method forcmd2.Cmdfor this niche case.If we had it to do over again, we would perhaps choose to use
pfeedbackinstead ofpoutputto output that info as it isn't really essential, but doing it at this point would be a breaking change which would pretty much be guaranteed to break someone else's application.