Exemplo n.º 1
0
def main():
    try:
        # Create the top-level parser
        desc = "Command line interface to the lunr storage api"
        parser = SubCommandParser([Backup(), Volume(), Env(),
                                   Tools(), Status(), Export()], desc=desc)
        # execute the command requested
        return parser.run()

    except LunrHttpError as e:
        print("Code: %s - %s" % (e.code, e.msg))
    except LunrError as e:
        print(str(e))
    except ShellError as e:
        print(e.msg)
        return e.help()
class TestSubCommands(TestCase):
    def setUp(self):
        self.parser = SubCommandParser([Api()])

    def test_opt_decorator(self):
        # run the 'create' method on sub command 'api'
        result = self.parser.run('api create --name derrick'.split())
        self.assertEqual(result, "create: derrick")

    def test_noargs(self):
        result = self.parser.run('api list'.split())
        self.assertEqual(result, "listing")

    def test_no_subcommand(self):
        result = self.parser.run('api'.split())
        self.assertEqual(result, "help")
class TestSubCommands(TestCase):

    def setUp(self):
        self.parser = SubCommandParser([Api()])

    def test_opt_decorator(self):
        # run the 'create' method on sub command 'api'
        result = self.parser.run('api create --name derrick'.split())
        self.assertEqual(result, "create: derrick")

    def test_noargs(self):
        result = self.parser.run('api list'.split())
        self.assertEqual(result, "listing")

    def test_no_subcommand(self):
        result = self.parser.run('api'.split())
        self.assertEqual(result, "help")
Exemplo n.º 4
0
def main():
    try:
        # Create the top-level parser
        desc = "Command line interface to the lunr api"
        parser = SubCommandParser([Backup(), Volume(), Env(),
                                  Node(), Export(), Account()],
                                  desc=desc)
        # execute the command requested
        return parser.run()

    except LunrHttpError as e:
        print("Code: %s - %s" % (e.code, e.msg))
        print(str(e))
    except LunrError as e:
        print(str(e))
    except ShellError as e:
        print(e.msg)
        return e.help()
    return 1
 def setUp(self):
     self.parser = SubCommandParser([Api()])
 def setUp(self):
     self.parser = SubCommandParser([Api()])