added clear terminal function
This commit is contained in:
parent
fcb23827e4
commit
891ea79d53
17
helper.go
17
helper.go
@ -1,5 +1,11 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"runtime"
|
||||||
|
)
|
||||||
|
|
||||||
func filter[T any](ss []T, test func(T) bool) (ret []T) {
|
func filter[T any](ss []T, test func(T) bool) (ret []T) {
|
||||||
for _, s := range ss {
|
for _, s := range ss {
|
||||||
if test(s) {
|
if test(s) {
|
||||||
@ -7,4 +13,15 @@ func filter[T any](ss []T, test func(T) bool) (ret []T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func clearTerminal() {
|
||||||
|
var cmd *exec.Cmd
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
cmd = exec.Command("cmd", "/c", "cls")
|
||||||
|
} else {
|
||||||
|
cmd = exec.Command("clear")
|
||||||
|
}
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
cmd.Run()
|
||||||
}
|
}
|
2
main.go
2
main.go
@ -11,6 +11,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
clearTerminal()
|
||||||
|
|
||||||
p := tea.NewProgram(initialModel())
|
p := tea.NewProgram(initialModel())
|
||||||
if _, err := p.Run(); err != nil {
|
if _, err := p.Run(); err != nil {
|
||||||
fmt.Printf("Alas, there's been an error: %v", err)
|
fmt.Printf("Alas, there's been an error: %v", err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user