Skip to content

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

@pygrum

Description

@pygrum

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions