google / subcommands

Go subcommand library.
Apache License 2.0
749 stars 48 forks source link

Prefix matching for subcommands #25

Open clconway opened 5 years ago

clconway commented 5 years ago

I'd like to be able to invoke a subcommand using a unique prefix instead of having to type an exact match. E.g., if "foo" defines subcommands "dobaz", "doqux" and "dropit", then

"foo dob", "foo doba" -> "foo dobaz"
"foo doq", "foo doqu" -> "foo doqux"
"foo dr", "foo dro", ... -> "foo dropit"
"foo d", "foo do" -> error, ambiguous prefix

This is sufficiently different behavior from previously that it should probably be optional, but I'm not sure how best to fit it in.

I have an implementation I use in my own code that I can contribute.