You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on an application where users are able to execute commands on a server, for this I decided to use this project (great work by the way!), some of these commands are asynchronous jobs which I run using goroutines. I'd like to write the output in the same terminal, however calling things like fmt.Println() breaks the current render.
If there a way I could do this? Eg using a method like InsertLineAboveInput() or something? Or maybe forcibly re-drawing the output? This is the example code I'm working with:
funcpollOutput() {
for {
time.Sleep(time.Second))
fmt.Println("Example line") // This breaks the outputprompt.InsertLineAboveInput("Example line") // Something like this, force redraw, etc
}
}
funcmain() {
gopollOutput() // Example, real implementation is more complexterm:=prompt.New(
executor,
completer,
prompt.OptionLivePrefix(func() (string, bool) {
ifcontext=="" {
return"shell>", true
} else {
returnfmt.Sprintf("shell(%s)> ", context), true
}
}),
)
term.Run()
}
Thanks a bunch for the reply!
The text was updated successfully, but these errors were encountered:
Question
I'm working on an application where users are able to execute commands on a server, for this I decided to use this project (great work by the way!), some of these commands are asynchronous jobs which I run using goroutines. I'd like to write the output in the same terminal, however calling things like
fmt.Println()
breaks the current render.If there a way I could do this? Eg using a method like
InsertLineAboveInput()
or something? Or maybe forcibly re-drawing the output? This is the example code I'm working with:Thanks a bunch for the reply!
The text was updated successfully, but these errors were encountered: