-
Notifications
You must be signed in to change notification settings - Fork 418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support recognizing abbreviated options and commands #10
Comments
Micronaut does this:
where class ScriptNameResolver {
/**
* Matches a camelCase scriptName to a potential scriptFileName in canonical form.<p>
* The following scriptNames match FooBar: FB, FoB, FBa
*/
static boolean resolvesTo(String scriptName, String scriptFileName) {
def scriptFileNameTokens = NameUtils.getNameFromScript(scriptFileName).findAll(/[A-Z][a-z]+/)
def scriptNameTokens = NameUtils.getNameFromScript(scriptName).findAll(/[A-Z][a-z]*/)
if (scriptFileNameTokens.size() != scriptNameTokens.size()) return false
for (int i = 0; i < scriptNameTokens.size(); i++) {
String str = scriptNameTokens[i]
if (!scriptFileNameTokens[i].startsWith(str)) return false
}
true
}
} and
|
Hi, any idea or suggestion about how this should be implemented? I saw your code snippet in #732, is that the preferred behaviour of this feature? |
Yes, the code in #732 is a good start for how I think this should work. Basically, options and commands can be abbreviated at word boundaries:
Note that the code in #732 is just a proof of concept to explore this problem. If there is a better (shorter, clearer) way to do this that is fine. The Map passed to the Note that the code to loop over the characters in the string is incorrect: see https://stackoverflow.com/questions/1527856/how-can-i-iterate-through-the-unicode-codepoints-of-a-java-string (instead of i++ the variable should be incremented by |
Created a draft PR #1047. |
http://bailando.berkeley.edu/papers/psb03.pdf
The text was updated successfully, but these errors were encountered: