main.go 838 B

123456789101112131415161718192021222324252627282930313233
  1. package main
  2. import (
  3. "fmt"
  4. "git.swzry.com/zry/go-hhc-cli/hhccli"
  5. "git.swzry.com/zry/go-hhc-cli/oldfiles"
  6. "golang.org/x/crypto/ssh/terminal"
  7. "os"
  8. )
  9. func main() {
  10. fdbg, err := os.OpenFile("debug.log", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
  11. defer func() { _ = fdbg.Close() }()
  12. if err != nil {
  13. fmt.Println("Failed Open Debug Log File:", err.Error())
  14. return
  15. }
  16. _, err = terminal.MakeRaw(int(os.Stdin.Fd()))
  17. if err != nil {
  18. fmt.Print("Failed Make Terminal Raw:", err.Error(), "\r\n")
  19. return
  20. }
  21. sysview := hhccli.NewCliView(maketree())
  22. cih := oldfiles.NewInteractiveCli(os.Stdin, os.Stdout, os.Stderr, "[GO-HHC-CLI]")
  23. cih.SetDebugOut(fdbg)
  24. cih.RegisterView("system", sysview)
  25. _ = cih.SetCurrentView("system")
  26. err = cih.Run()
  27. if err != nil {
  28. fmt.Print("Failed Processing CLI:", err.Error(), "\r\n")
  29. return
  30. }
  31. }