Skip to content
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

Provide the option to not completely override the original completer #63

Open
pygrum opened this issue Dec 27, 2023 · 0 comments
Open

Comments

@pygrum
Copy link

pygrum commented Dec 27, 2023

Thanks for the library! This issue is really a feature request.

Request

It would be useful to me and potentially others to not have the default completer completely overriden once a non-nil completer is provided. This is because I'd still like to use original flag and sub-command completion if the parent command has a custom completer.

Proposal

I propose that the decision in the completion function here is modified to:

if cmd.Completer != nil {
	words = cmd.Completer(prefix, rest)
	for _, w := range words {
		suggestions = append(suggestions, []rune(strings.TrimPrefix(w, prefix)))
	}
        if cmd.OverrideCompleter {
                return suggestions, len(prefix)
        }
}

This means that grumble.Command would have a new field like OverrideCompleter (which could be set to 'true' by default to preserve original behaviour). If I'm not mistaken, the following change would mean that the custom completion results as well as the default completion results would be suggested when TAB is hit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant