Skip to content

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

Open
@mayamshah

Description

@mayamshah

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions