package app import ( "flag" "os" ) type Config struct { WindowWidth int WindowHeight int Fullscreen bool } func ParseConfig() Config { cfg := Config{ WindowWidth: 1280, WindowHeight: 720, Fullscreen: envBool("KIDSKEYBOARD_FULLSCREEN"), } flag.IntVar(&cfg.WindowWidth, "width", cfg.WindowWidth, "window width") flag.IntVar(&cfg.WindowHeight, "height", cfg.WindowHeight, "window height") flag.BoolVar(&cfg.Fullscreen, "fullscreen", cfg.Fullscreen, "start in fullscreen mode") flag.Bool("windowed", false, "force windowed mode") flag.Parse() if flag.Lookup("windowed") != nil { if v := flag.Lookup("windowed").Value.String(); v == "true" { cfg.Fullscreen = false } } return cfg } func envBool(name string) bool { switch os.Getenv(name) { case "1", "true", "TRUE", "yes", "YES", "on", "ON": return true default: return false } }