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

add SetChildren for prefix completer interface #38

Merged
merged 1 commit into from
Mar 16, 2016
Merged

add SetChildren for prefix completer interface #38

merged 1 commit into from
Mar 16, 2016

Conversation

buaazp
Copy link
Contributor

@buaazp buaazp commented Mar 16, 2016

In my case, I need update prefix completer in background, so I need this SetChildren method for prefix completer interface.

See the codes below, I need get server list first and then update the completer:

func updateServerList() {
    svrList, err := getServers()
    if err != nil {
        fmt.Fprintf(tty.Stderr(), "\r\nconnect to %s err: %s\r\n",
            color.Bold(framer), err)
    }
    if svrList == nil {
        return
    }

    updateCompleter(svrList)
}

func updateCompleter(svrList []string) {
    var tcServersCompleter []readline.PrefixCompleterInterface
    for _, host := range svrList {
        tcServersCompleter = append(tcServersCompleter, readline.PcItem(host))
    }
    for _, child := range completer.GetChildren() {
        childName := string(child.GetName())
        switch childName {
        case "setmaster ",
            "serveradd ",
            "serverstat ",
            "serverdel ",
            "serveroffline ",
            child.SetChildren(tcServersCompleter)
        default:
            continue
        }
    }
}

chzyer added a commit that referenced this pull request Mar 16, 2016
add SetChildren for prefix completer interface
@chzyer chzyer merged commit 402307d into chzyer:master Mar 16, 2016
@chzyer
Copy link
Owner

chzyer commented Mar 16, 2016

Thanks 😄

@buaazp
Copy link
Contributor Author

buaazp commented May 9, 2016

I found this commit is not existed in gopkg.in/readline.v1 version. Need help.

@chzyer
Copy link
Owner

chzyer commented May 9, 2016

@buaazp
I just release a new version. This PR will be included in gopkg.in/readline.v1 now.

@buaazp
Copy link
Contributor Author

buaazp commented May 9, 2016

Great!

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

Successfully merging this pull request may close these issues.

2 participants