manifoldco / promptui

Interactive prompt for command-line applications
https://www.manifold.co
BSD 3-Clause "New" or "Revised" License
6.03k stars 333 forks source link

How do you hide the cursor after inputting text? + Other stylistic comments #153

Open mayamshah opened 4 years ago

mayamshah commented 4 years ago

Hi,

I am using the latest version of promptui. I created a REPL and I am using promptui to grab the users input. However after every new input the cursor doesn't disappear. I've looked through the documentation but I am unsure how to fix this issue.

Here is what my shell looks like:

Screen Shot 2020-06-11 at 3 58 24 PM

I also noticed randomly sometimes when I input a string, the output is given twice. (this happens randomly, but an example is when "banana" was entered in the above screenshot)

I also noticed sometimes "op:" is greyed out, and sometimes it keeps the green check. Do you know how to fix these issues?

Here is the code that is running promptui:

func Run(execute bool) {

    t := tool_chain.NewOpToolChain()

    for true {

        validate_exp := func (input string) error {
            _,_,_, err := t.Parse(input)
            return err
        }

        prompt := promptui.Prompt{
            Label:    "op",
            Validate: validate_exp,
        }

        result, err := prompt.Run()

        if err != nil {
            fmt.Printf("Prompt failed %v\n", err)
            return
        }

        //exits the interative cli if user specifies
        if result == `exit` {
            fmt.Printf("CLI exiting gracefully...")
            break

        //executes the command given
        } else {
            fmt.Printf("Command entered: %q\n", result)
        }
    }
}

Let me know if there is something I can do.

Thanks, Maya

jrslv commented 4 years ago

Hi, this is fixed in https://github.com/manifoldco/promptui/pull/147

seyoatda commented 3 years ago

Hi, this is fixed in #147

it seems this bug still exists in v0.8.0 , in windows powershell