remove junk

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-01-15 08:17:07 -08:00
parent 3ad06351ae
commit aa46ffffe4
2 changed files with 12 additions and 22 deletions

View File

@ -4,6 +4,10 @@ package main
This simply parses the command line arguments using the default golang This simply parses the command line arguments using the default golang
package called 'flag'. This can be used as a simple template to parse package called 'flag'. This can be used as a simple template to parse
command line arguments in other programs. command line arguments in other programs.
It puts everything in the 'config' package which I think is a good
wrapper around the 'flags' package and doesn't need a whole mess of
global variables
*/ */
import "log" import "log"
@ -27,11 +31,9 @@ var customUsage = func() {
func parseFlags() { func parseFlags() {
var version string var version string
var race bool var race bool
// var debug = os.Getenv("BUILDDEBUG") != ""
var filename string var filename string
var width int var width int
var height int var height int
// var timeout = "120s"
var glDrift float64 var glDrift float64
flag.StringVar (&version, "version", "v0.1", "Set compiled in version string") flag.StringVar (&version, "version", "v0.1", "Set compiled in version string")
@ -45,15 +47,14 @@ func parseFlags() {
// Set the output if something fails to stdout rather than stderr // Set the output if something fails to stdout rather than stderr
flag.CommandLine.SetOutput(os.Stdout) flag.CommandLine.SetOutput(os.Stdout)
// flag.SetOutput(os.Stdout)
flag.Usage = customUsage flag.Usage = customUsage
flag.Parse() flag.Parse()
if flag.Parsed() { if flag.Parsed() {
log.Println("Parsed() worked") log.Println("flag.Parse() worked")
} else { } else {
log.Println("Parsed() failed") log.Println("flag.Parse() failed")
} }
// keys := []string{"filename", "width", "height", "drift"} // keys := []string{"filename", "width", "height", "drift"}
@ -64,15 +65,15 @@ func parseFlags() {
config.Set("width", width) config.Set("width", width)
config.Set("height", height) config.Set("height", height)
config.Set("uDrift", glDrift)
config.Set("filename", filename) config.Set("filename", filename)
// uDrift = float32(tmp)
} }
func parseConfig() { func parseConfig() {
config.WithOptions(config.ParseEnv) config.WithOptions(config.ParseEnv)
parseFlags() parseFlags()
// config.LoadOSEnv([]string{"MAIL"}) config.LoadOSEnv([]string{"MAIL"})
// config.LoadOSEnv([]string{"USER"}) config.LoadOSEnv([]string{"USER"})
config.LoadOSEnv([]string{"BUILDDEBUG"})
} }

View File

@ -10,11 +10,12 @@ import (
"golang.org/x/image/colornames" "golang.org/x/image/colornames"
) )
import "fmt" import "log"
import "github.com/gookit/config" import "github.com/gookit/config"
func run() { func run() {
// Set up window configs // Set up window configs
log.Println("width = ", config.Int("width"), "height = ", config.String("height"))
cfg := pixelgl.WindowConfig{ // Default: 1024 x 768 cfg := pixelgl.WindowConfig{ // Default: 1024 x 768
Title: "Golang GLSL", Title: "Golang GLSL",
Bounds: pixel.R(0, 0, config.Float("width"), config.Float("height")), Bounds: pixel.R(0, 0, config.Float("width"), config.Float("height")),
@ -79,17 +80,5 @@ func main() {
// This parses the command line arguments // This parses the command line arguments
parseConfig() parseConfig()
name := config.String("name")
fmt.Println("name = ", name)
fmt.Println("name2 = ", config.String("name2"))
fmt.Println("width = ", config.Int("width"))
fmt.Println("height = ", config.String("height"))
fmt.Println("drift = ", config.Int("drift"))
fmt.Println("filename = ", config.String("filename"))
fmt.Println("MAIL=", config.String("MAIL"))
fmt.Println("mail=", config.String("mail"))
fmt.Println("USER=", config.String("USER"))
pixelgl.Run(run) pixelgl.Run(run)
} }