Need help with interact?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

deiwin
129 Stars 4 Forks MIT License 10 Commits 0 Opened issues

Description

A Golang utility belt for interacting with the user over a CLI

Services available

!
?

Need anything else?

Contributors list

# 55,379
github-...
datadog
CSS
css-fra...
10 commits

Interact

A Golang utility belt for interacting with the user over a CLI

Build Status Coverage GoDoc

Example interaction

Code like this: ```go actor := interact.NewActor(os.Stdin, os.Stdout)

message := "Please enter something that's not empty" notEmpty, err := actor.Prompt(message, checkNotEmpty) if err != nil { log.Fatal(err) } message = "Please enter a positive number" n1, err := actor.PromptAndRetry(message, checkNotEmpty, checkIsAPositiveNumber) if err != nil { log.Fatal(err) } message = "Please enter another positive number" n2, err := actor.PromptOptionalAndRetry(message, "7", checkNotEmpty, checkIsAPositiveNumber) if err != nil { log.Fatal(err) } fmt.Printf("Thanks! (%s, %s, %s)\n", notEmpty, n1, n2) ```

Can create an interaction like this:

asciicast

For a more comprehensive example see the example test.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.