How to structure a python cmd application which has separate command modules
<p>I'm writing a python command-line tool using the cmd2 module which is an enhanced version of cmd. The tool is an administration application and is used to administer a number of sub-modules.</p>

<p>I'd like to structure the code so that each sub-module has its own class responsible for providing the commands that can be executed on that module. But I'm not sure how to structure this given how the command class works.</p>

<p>So what I'd like is something like:</p>

<pre><code>import cmd

class ConsoleApp(cmd.Cmd):

    # this is the main app and should get the commands from the sub-modules

app = ConsoleApp()
app.cmdloop()
</code></pre>

<p>And then the sub-modules would be separately defined.</p>

<pre><code>class SubModuleA():

    def do_sm_a_command_1(self, line):
        print "sm a command 1"

class SubModuleB():

    def do_sm_b_command_1(self, line):
        print "sm b command 2"
</code></pre>

<p>How can I structure this so that the main app will pick up the commands from the sub-modules?</p>

<p>Thanks, Jon</p>
