main.go 647 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. The zygomys command line REPL is known as `zygo`.
  3. */
  4. package main
  5. import (
  6. "flag"
  7. "fmt"
  8. "github.com/glycerine/zygomys/v6/zygo"
  9. "os"
  10. )
  11. func usage(myflags *flag.FlagSet) {
  12. fmt.Printf("zygo command line help:\n")
  13. myflags.PrintDefaults()
  14. os.Exit(1)
  15. }
  16. func main() {
  17. cfg := zygo.NewZlispConfig("zygo")
  18. cfg.DefineFlags()
  19. err := cfg.Flags.Parse(os.Args[1:])
  20. if err == flag.ErrHelp {
  21. usage(cfg.Flags)
  22. }
  23. if err != nil {
  24. panic(err)
  25. }
  26. err = cfg.ValidateConfig()
  27. if err != nil {
  28. fmt.Fprintf(os.Stderr, "zygo command line error: '%v'\n", err)
  29. usage(cfg.Flags)
  30. }
  31. // the library does all the heavy lifting.
  32. zygo.ReplMain(cfg)
  33. }