Commits

John Mulligan committed 7e3b657

fix subcommands with names where c1.startswith(c2) is true

If the user specified cmd name is exactly equal to a command with
multiple matches, the exact match is used, otherwise you are ambiguous.

Comments (0)

Files changed (2)

     (cmd1, 'draw', OPTIONS2, 'Draw on slate'),
     (cmd2, 'wipe', [], 'Wipe slate'),
     (cmd3, 'window', [], 'Open a new window'),
+    (cmd3, 'fit', [], 'rezise objects to fit on slate'),
+    (cmd3, 'fitness', [], 'check if all objects fit'),
     ]
 
 CLI10 = 'draw fribble.s'
 CLI13 = 'dr --help -d /home/blarg --skip-checks fribble.s'
 CLI14 = '--help --skip-checks dr -d . fribble.s'
 CLI15 = '--help'
-
+CLI16 = "fit womp.s"
+CLI17 = "fi womp.s"
     
 
 
         self.assertFalse(opts['debug'])
         self.assertTrue(opts['help'])
 
+    def test_cli_16(self):
+        fn, opts, args = cli.parsecommand(OPTIONS3, COMMANDS1, CLI16.split())
+        self.assertTrue(fn == cmd3)
+
+    def test_cli_17(self):
+        self.assertRaises(
+            cli.AmbiguousCommand,
+            cli.parsecommand,
+            OPTIONS3, COMMANDS1, CLI17.split()
+            )
+
 
     def test_parse_sample_1(self):
         opts, args = cli.parse(TABLE_A, SAMPLE1)
             return matches[0]
         if not matches:
             raise InvalidCommand(label)
+        if label in self._table.keys():
+            #exact match
+            return label
         raise AmbiguousCommand(label, matches)
 
     def lookup(self, label):