https://github.com/gbrlsnchs/prompt
Agnostic prompt for Golang programs
https://github.com/gbrlsnchs/prompt
go golang input prompt stdin
Last synced: about 2 months ago
JSON representation
Agnostic prompt for Golang programs
- Host: GitHub
- URL: https://github.com/gbrlsnchs/prompt
- Owner: gbrlsnchs
- License: mit
- Created: 2019-06-08T14:11:01.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-07-13T21:25:09.000Z (about 6 years ago)
- Last Synced: 2025-08-19T07:58:02.731Z (about 2 months ago)
- Topics: go, golang, input, prompt, stdin
- Language: Go
- Homepage:
- Size: 29.3 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# prompt
[](https://circleci.com/gh/gbrlsnchs/prompt)
[](https://godoc.org/github.com/gbrlsnchs/prompt)Agnostic prompt for Go.
## Usage
### Example
#### Confirming input from stdin
```go
import "gsr.dev/prompt"func main() {
p := prompt.New()
confirm := p.Confirm(prompt.Inputs{
"yes": true,
"no": false,
})
}
```#### Using options
##### Case insensitive prompt
```go
import "gsr.dev/prompt"func main() {
p := prompt.New(prompt.CaseInsensitive)
confirm := p.Confirm(prompt.Inputs{
"yes": true,
"no": false,
})
}
```##### Reading from another source
```go
import (
"strings""gsr.dev/prompt"
)func main() {
r := strings.NewReader("yes\n")
p := prompt.New(prompt.ReadFrom(r))
confirm := p.Confirm(prompt.Inputs{
"yes": true,
"no": false,
})
}
```