Skip to content

add SetChildren for prefix completer interface#38

Merged
chzyer merged 1 commit into
chzyer:masterfrom
buaazp:master
Mar 16, 2016
Merged

add SetChildren for prefix completer interface#38
chzyer merged 1 commit into
chzyer:masterfrom
buaazp:master

Conversation

@buaazp
Copy link
Copy Markdown
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
Copy Markdown
Owner

chzyer commented Mar 16, 2016

Thanks 😄

@buaazp
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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