diff --git a/cmd/root.go b/cmd/root.go index 2aeda15..470ae2f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -44,6 +44,22 @@ func (s *script) load(path string) error { return err } +func getPresets() []string { + var presets []string + + if preset != "" { + presets = []string{preset} + } + + if scriptPath != "" { + var s script + s.load(scriptPath) + presets = s.Presets + } + + return presets +} + func handleWindowEvent(event *sdl.WindowEvent, m *milkDropWindow) { switch event.Event { case sdl.WINDOWEVENT_RESIZED: @@ -84,24 +100,14 @@ func milkbucket(cmd *cobra.Command, args []string) { log.Fatal("nothing to read from stdin") } - var presets []string - - if preset != "" { - presets = []string{preset} - } - - if scriptPath != "" { - var s script - s.load(scriptPath) - presets = s.Presets - } - err = sdl.Init(sdl.INIT_VIDEO) if err != nil { panic(err) } defer sdl.Quit() + presets := getPresets() + m, err := newMilkDropWindow(800, 600, presets) if err != nil { panic(err)