Skip to content

add SetChildren for prefix completer interface - #38

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

chzyer merged 1 commit into
chzyer:masterfrom
buaazp:master

Conversation

@buaazp

@buaazp buaazp commented Mar 16, 2016

Copy link
Copy Markdown
Contributor

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

chzyer commented Mar 16, 2016

Copy link
Copy Markdown
Owner

Thanks 😄

@buaazp

buaazp commented May 9, 2016

Copy link
Copy Markdown
Contributor Author

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

@chzyer

chzyer commented May 9, 2016

Copy link
Copy Markdown
Owner

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

@buaazp

buaazp commented May 9, 2016

Copy link
Copy Markdown
Contributor Author

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

⌂ 换网址