Customise Python Cmd Module Default Error Message

Viewed 251

I am building command-line utility, using python cmd module. Now I want change the default *** Unknown syntax: ds something like this [-] Unknown command: ds.

Is it possible to change that?

1 Answers

Yes, you simply need to override the default() method:

class MyCmd(cmd.Cmd):
    def default(self, line):
        self.stdout.write('[-] Unknown command: %s\n' % (line,))
Related