class testCmdparse(unittest.TestCase): def setUp(self): self.parser = CommandParser() self.parser.add_commands(testCommands) def tearDown(self): del self.parser def testEcho(self): (command, options, args) = self.parser.parse_args("echo foo".split()) self.assert_(isinstance(command, testCommands.EchoCommand))
def main(): parser = CommandParser(usage="%prog [command]", version='0.1') parser.add_command(ListCommand()) command, opts, args = parser.parse_args() if command is None: parser.print_help() return 1 return command.run(opts, args) return 0
def setUp(self): self.parser = CommandParser() self.parser.add_commands(testCommands)