[CLI Project] Portioning Commands as Singular or Plural
Rajeev S writes:
The commands surely do become more intuitive and make more sense, but this has a negative,the number of commands almost doubles.
The number of instances of "class Command" or whatever it's called doesn't need to double, though. You could simply have the parser recognize the relevant plurals as equivalent to the corresponding singular forms. If you want to make life hard, you could do that but in addition in the parse constrain the command to number agreement (ie, singular forms of the command must take exactly one argument, while the plural form must take zero, two, or more arguments).
You could really cheat by simply matching the shortest unambiguous prefix, so that
show usersallofthemifyouplease
shows all the users, and (probably) just "show u" does too. I think this is perhaps the most efficient solution, although it's not obvious that unsophisticated users would like it as much as us greybeards do. For bonus points, if the prefix is ambiguous, show the matching possibilities. A trie might be a good data structure for this, and you could build it on the fly from the list of command names (where ambiguity would of course be a fatal error).
Finally, if you *do* allow abbreviations, you should restrict that usage to interactive use; scripts should not be allowed to abbreviate (they'll break if a new command makes the abbreviation ambiguous).
participants (1)
-
Stephen J. Turnbull