| 505 | self.assertEqual(groups[2].results, matchedresult[1]) |
| 506 | |
| 507 | def test_multiple_nests(self): |
| 508 | cmd = "withargs withargs -b arg bar" |
| 509 | |
| 510 | matchedresult = [ |
| 511 | [MR(0, 8, "withargs synopsis", "withargs")], |
| 512 | [ |
| 513 | MR(9, 17, "withargs synopsis", "withargs"), |
| 514 | MR(18, 24, "-b <arg> desc", "-b arg"), |
| 515 | ], |
| 516 | [MR(25, 28, "bar synopsis", "bar")], |
| 517 | ] |
| 518 | |
| 519 | groups = matcher.Matcher(cmd, s).match() |
| 520 | self.assertEqual(len(groups), 4) |
| 521 | self.assertEqual(groups[0].results, []) |
| 522 | self.assertEqual(groups[1].results, matchedresult[0]) |
| 523 | self.assertEqual(groups[2].results, matchedresult[1]) |
| 524 | self.assertEqual(groups[3].results, matchedresult[2]) |
| 525 | |
| 526 | def test_nested_command_is_unknown(self): |
| 527 | cmd = "withargs -b arg unknown" |