'How can I define methods in Cmd class to use commands in the commands-line?

I know that I can define a method for a command :

class foo(cmd.Cmd):
    def do_create(self, line):
        """Code"""

But I want to define methods in the Cmd class to use commands in the commands-line in the form User.command(arg). For example:

$ User.create("Pep")

Is there some method of the Cmd class that I have to modify?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source