interact

by deiwin

deiwin /interact

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

131 Stars 4 Forks Last release: Not found MIT License 10 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

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.