Question/answer and multiple choice by command line
Repo oxequa/interact, read from GitHub 8 h ago. oxequa has not joined Take My Repo.
oxequa/interact is a public repo on GitHub by oxequa. Question/answer and multiple choice by command line. It declares the GPL-3.0 license on GitHub. It is written mainly in Go, has 42 stars and last changed on 2017-12-16. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-23.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
An easy and fast Go library, without external imports, to handle questions and answers by command line
To install interact:
$ go get github.com/tockins/interact
Run a simple question and manage the response. The response field is used to get the answer as a specific type.
package main
import (
i "github.com/tockins/interact"
)
func main() {
i.Run(&i.Interact{
Questions: []*i.Question{
{
Quest: i.Quest{
Msg: "Would you like some coffee?",
},
Action: func(c i.Context) interface{} {
val, err := c.Ans().Bool()
if err != nil{
return err
}
fmt.Println(val)
return nil
},
},
},
})
}
Define a list of questions to be run in sequence. The Action func can be used for validate the answer and can return a custom error.
Question struct is only for single question whereas Interact struct supports multiple questions
package main
import (
i "github.com/tockins/interact"
)
func main() {
i.Run(&i.Interact{
Questions: []*i.Question{
{
Quest: i.Quest{
Msg: "Would you like some coffee?",
},
Action: func(c i.Context) interface{} {
val, err := c.Ans().Bool()
if err != nil{
return err
}
fmt.Println(val)
return nil
},
},
{
Quest: i.Quest{
Msg: "What's 2+2?",
},
Action: func(c i.Context) interface{} {
val, _ := c.Ans().Int()
// get the answer as integer
if val < 4 {
// return a custom error and rerun the question
return "INCREASE"
}else if val > 4 {
return "DECREASE"
}
return nil
},
},
},
})
}
Define a multiple choice question
package main
import (
i "github.com/tockins/interact"
)
func main() {
i.Run(&i.Interact{
Questions: []*i.Question{
{
Quest: i.Quest{
Msg: "how much for a teacup?",
Choices: i.Choices{
Alternatives: []i.Choice{
{
Text: "Gyokuro teapcup",
Response: "20",
},
{
Text: "Sencha teacup",
Response: -10,
},
{
Text: "Matcha teacup",
Response: 15.50,
},
},
},
},
Action: func(c i.Context) interface{} {
val, _ := c.Ans().Int()
fmt.Println(val)
return nil
},
},
},
})
}
The sub questions list is managed by the "Resolve" func. Each sub question can access to the parent answer by the "Parent" method
package main
import (
i "github.com/tockins/interact"
)
func main() {
i.Run(&i.Interact{
Questions: []*i.Question{
{
Quest: i.Quest{
Msg: "Would you like some coffee?",
Resolve: func(c i.Context) bool {
val, _ := c.Ans().Bool()
return val
},
},
Subs: []*i.Question{
{
Quest: i.Quest{
Msg: "What Kind of Coffee?",
Choices: i.Choices{
Alternatives: []i.Choice{
{
Text: "Black coffee",
Response: "black",
},
{
Text: "With milk",
Response: "milk",
},
},
},
},
Action: func(c i.Context) interface{} {
// question (sub) answer
val, _ := c.Ans().String()
fmt.Println(val)
// parent answer
val, _ = c.Parent().Ans().String()
fmt.Println(val)
return nil
},
},
},
Action: func(c i.Context) interface{} {
// question answer
val, _ := c.Ans().String()
fmt.Println(val)
// sub question answer
fmt.Println(c.Qns().Get(0).Ans().Raw())
return nil
},
},
},
})
}
Interact support a custom prefix for each question
You can define a global prefix for all questions but you can overwrite it in each question with ease
As the first param you can pass a custom io.writer instance
package main
import (
i "github.com/tockins/interact"
)
func main() {
i.Run(&i.Interact{
Before: func(c i.Context) error{
c.SetPrfx(nil,"GLOBAL PREFIX")
return nil
},
Questions: []*i.Question{
{
Before: func(c i.Context) error{
c.SetPrfx(nil,"OVERWRITTEN PREFIX")
// print current prefix
fmt.Println(c.Prfx())
return nil
},
Quest: i.Quest{
Msg: "Would you like some coffee?",
},
Action: func(c i.Context) interface{} {
return nil
},
},
{
Before: func(c i.Context) error{
fmt.Println(c.Prfx())
return nil
},
Quest: i.Quest{
Msg: "What's 2+2?",
},
Action: func(c i.Context) interface{} {
return nil
},
},
},
})
}
You can define a default value for each question and get it in the action func as an answer
package main
import (
i "github.com/tockins/interact"
)
func main() {
i.Run(&i.Interact{
Questions: []*i.Question{
{
Before: func(c i.Context) error{
c.SetDef("test",default val")
return nil
},
Quest: i.Quest{
Msg: "Would you like some coffee?",
},
Action: func(c i.Context) interface{} {
val, _ := c.Ans().String()
fmt.Println(val)
return nil
},
},
{
Before: func(c i.Context) error{
c.SetDef("default","default val")
return nil
},
Quest: i.Quest{
Msg: "Would you like some coffee?",
},
Action: func(c i.Context) interface{} {
val, _ := c.Ans().Bool()
fmt.Println(val)
return nil
},
},
},
})
}
You can define a default error for every question or you can set a default error message
package main
import (
i "github.com/tockins/interact"
)
func main() {
i.Run(&i.Interact{
Before: func(c i.Context) error{
c.SetErr("Default error")
return nil
},
Questions: []*i.Question{
{
Quest: i.Quest{
Msg: "Would you like some coffee?",
Err: "Custom error fot this question",
},
Action: func(c i.Context) interface{} {
val, err := c.Ans().Bool()
if err {
return "Invalid answer"
}
return nil
},
},
{
Quest: i.Quest{
Msg: "Would you like some coffee?",
},
Action: func(c i.Context) interface{} {
val, err := c.Ans().Bool()
if err {
return c.Err()
}
return nil
},
},
},
})
}
For every question and for each list of questions you can define custom commands to be run before or after the relative instance
package main
import (
i "github.com/tockins/interact"
)
function main(){
i.Run(&i.Interact{
Before: func(c i.Context) error{
c.SetPrfx(nil, "TEST")
return nil
},
Questions: []*i.Question{
{
Before: func(c i.Context) error{
c.SetPrfx(nil, "TEST A")
return nil
},
Quest: i.Quest{
Msg: "How much coffee?",
},
Action: func(c i.Context) interface{} {
return nil
},
After: func(c i.Context) error{
val, _ := c.Ans().Int()
fmt.Println(val)
return nil
},
},
{
Quest: i.Quest{
Msg: "How much coffee?",
},
Action: func(c i.Context) interface{} {
return nil
},
},
},
After: func(c i.Context) error{
for _, v := range c.Qns().List(){
fmt.Println(v.Quest(),v.Ans().Raw())
}
return nil
},
})
}
With the skip func you can stop the execution of the current question or you can skip the next.
package main
import (
i "github.com/tockins/interact"
)
function main(){
i.Run(&i.Interact{
Before: func(c i.Context) error{
// skip all questions
//c.Skip()
return nil
},
Questions: []*i.Question{
{
Before: func(c i.Context) error{
// skip the current question
//c.Skip()
return nil
},
Quest: i.Quest{
Msg: "How much coffee?",
},
Action: func(c i.Context) interface{} {
return nil
},
After: func(c i.Context) error{
// skip the next question
c.Skip()
return nil
},
},
{
Before: func(c i.Context) error{
return nil
},
Quest: i.Quest{
Msg: "How much tea?",
},
Action: func(c i.Context) interface{} {
return nil
},
After: func(c i.Context) error{
return nil
},
},
},
})
}
You can reload a question how many times as you want
package main
import (
i "github.com/tockins/interact"
)
function main(){
i.Run(&i.Interact{
Questions: []*i.Question{
{
Quest: i.Quest{
Msg: "Would you like Interact?",
},
Action: func(c i.Context) interface{}{
val, err := c.Ans().Bool()
if (err != nil || !val){
c.Reload()
}
return nil
},
},
},
})
}
End a group of questions or sub-questions with a specific character or string
package main
import (
i "github.com/tockins/interact"
)
func main() {
i.Run(&i.Interact{
Before: func(c i.Context) error {
c.SetEnd("!*")
return nil
},
Questions: []*i.Question{
{
Before: func(c i.Context) error {
c.SetEnd("*")
return nil
},
Quest: i.Quest{
Msg: "Would you like some coffee? (insert '*' to stop this question or the sub questions)",
Resolve: func(c i.Context) bool {
val, _ := c.Ans().Bool()
return val
},
},
Subs: []*i.Question{
{
Before: func(c i.Context) error {
c.SetEnd("!")
return nil
},
Quest: i.Quest{
Msg: "What kind of Coffee? (insert '!' to stop)",
},
Action: func(c i.Context) interface{} {
c.Reload()
return nil
},
},
{
Quest: i.Quest{
Msg: "What type of Coffee?",
},
},
},
},
{
Quest: i.Quest{
Msg: "Would you like some tea?",
},
Action: func(c i.Context) interface{} {
c.Reload()
return nil
},
},
},
})
}
Interact supports the color scheme defined by the package "fatih/color"
package main
import (
"github.com/fatih/color"
i "github.com/tockins/interact"
"fmt"
)
func main() {
b := color.New(color.FgHiWhite).Add(color.BgRed).SprintfFunc()
y := color.New(color.FgYellow).SprintFunc()
r := color.New(color.FgRed).SprintFunc()
g := color.New(color.FgGreen).SprintFunc()
prefix := y("[") + "INTERACT" + y("]")
i.Run(&i.Interact{
Before: func(c i.Context) error{
c.SetPrfx(color.Output, prefix)
return nil
},
Questions: []*i.Question{
{
Before: func(c i.Context) error{
c.SetPrfx(nil,y("[") + "INTERACT QUEST" + y("]"))
return nil
},
Quest: i.Quest{
Msg: "Would you like some coffee?",
Options: g("[yes/no]"),
Err: b("INVALID"),
Resolve: func(c i.Context) bool{
val, _ := c.Ans().Bool()
return val
},
},
Subs: []*i.Question{
{
Quest: i.Quest{
Msg: "What Kind of Coffee?",
Err: b("INVALID"),
Choices: i.Choices{
Color: g,
Alternatives: []i.Choice{
{
Text: "Black coffee",
Response: "black",
},
{
Text: "With milk",
Response: "milk",
},
},
},
},
Action: func(c i.Context) interface{}{
val, _ := c.Ans().String()
fmt.Println(val)
val, _ := c.Parent().Ans().String()
fmt.Println(val)
return nil
},
},
},
Action: func(c i.Context) interface{} {
val, _ := c.Ans().Bool()
if !val{
return r("INVALID INPUT")
}
fmt.Println(c.Quest(), val)
return nil
},
},
},
})
}
oxequa/interact is a public repo on GitHub by oxequa. Question/answer and multiple choice by command line.
It declares the GPL-3.0 license on GitHub.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2017-12-16. GitHub counts 0 open issues and pull requests. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.
Visualize call graph of a Go program using Graphviz
Your Cheat Sheet For Android Interview - Android Interview Questions and Answers

Automatically generate Go test boilerplate from your source code.

🔥🔥「InterviewGuide」是阿秀从校园->职场多年计算机自学过程的记录以及学弟学妹们计算机校招&秋招经验总结文章的汇总,包括但不限于C/C++ 、Golang、JavaScript、Vue、操作系统、数据结构、计算机网络、MySQL、Redis等学习总结,坚持学习,持续成长!

Realize is the #1 Golang Task Runner which enhance your workflow by automating the most common tasks and using the best performing Golang live reloading.

Handle Go recover, panic, and errors in a graceful way. Multiple errors support, basic filters and custom handlers.
Flutter plugin to load and cache network or firebase storage images with a retry mechanism if the download fails
Fresh is a lightweight and high performance RESTful framework ready to use for environments where scaling is needed.
Take My Repo has not tested this on your machine. Requirements come from the project's own documentation.