Skip to content

Add readline timeout #15

@neutronstein

Description

@neutronstein

Add support for timeout when reading line.

Activity

neutronstein

neutronstein commented on Feb 8, 2017

@neutronstein
Author

I used this workaround. I hope it will help.

func CommandHandler(c *ishell.Context) {
    select {
    case <-time.After(10 * time.Second):
        c.Println("\n\n[[ Session timed out! ]]\n")
        return
    case input := <-readLine(c):
        c.Println("You wrote: "+ input)
        return
    }
}

func readLine(c *ishell.Context) (chan string) {
    inputChan := make(chan string)
    go func() {
        inputChan <- c.ReadLine()
    }()
    return inputChan
}
abiosoft

abiosoft commented on May 30, 2017

@abiosoft
Owner

The main issue is the limitation with the readline library that ishell depends on. I haven't figured a way to interrupt a readline without keyboard input.

Until then, this issue may not have a proper fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @abiosoft@neutronstein

        Issue actions

          Add readline timeout · Issue #15 · abiosoft/ishell