added clear terminal function

This commit is contained in:
june 2025-03-09 11:17:48 +13:00
parent fcb23827e4
commit 891ea79d53
Signed by untrusted user who does not match committer: breadone
GPG Key ID: FDC19FE143200483
2 changed files with 19 additions and 0 deletions

View File

@ -1,5 +1,11 @@
package main
import (
"os"
"os/exec"
"runtime"
)
func filter[T any](ss []T, test func(T) bool) (ret []T) {
for _, s := range ss {
if test(s) {
@ -8,3 +14,14 @@ func filter[T any](ss []T, test func(T) bool) (ret []T) {
}
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()
}

View File

@ -11,6 +11,8 @@ import (
)
func main() {
clearTerminal()
p := tea.NewProgram(initialModel())
if _, err := p.Run(); err != nil {
fmt.Printf("Alas, there's been an error: %v", err)