Beispiel #1
0
    def test_get_usage(self):
        command = Command()
        command.add_option("foo", Option("-o", String()))
        self.assert_equal(command.get_usage(), u("[-h] [-o foo]"))

        command.add_command("bar", Command())
        self.assert_equal(command.get_usage(), u("[-h] [-o foo] {bar}"))

        command.add_positional(String(metavar="baz"))
        self.assert_equal(command.get_usage(), u("[-h] [-o foo] {bar} baz"))
Beispiel #2
0
 def test_add_command(self):
     command = Command()
     command.add_command("foobar", Command())
     command.add_command("foobar", Command(), force=True)
     with self.assert_raises(CommandConflict):
         command.add_command("foobar", Command())