Skip to content

Commit

Permalink
do not panic on nonexistant screensaver
Browse files Browse the repository at this point in the history
  • Loading branch information
vilmibm committed Sep 23, 2021
1 parent eb31a3d commit 36ad1d9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ func runScreensaver(opts shared.ScreensaverOpts) error {
style := tcell.StyleDefault
opts.Style = style

saverInit, ok := opts.Savers[opts.Screensaver]
if !ok {
return fmt.Errorf("no such screensaver '%s'; run gh screensaver -l to see choices", opts.Screensaver)
}

screen, err := tcell.NewScreen()
if err != nil {
return err
Expand All @@ -29,7 +34,7 @@ func runScreensaver(opts shared.ScreensaverOpts) error {

opts.Screen = screen

saver, err := opts.Savers[opts.Screensaver](opts)
saver, err := saverInit(opts)
if err != nil {
return err
}
Expand Down Expand Up @@ -182,7 +187,6 @@ func main() {
rc := rootCmd()

if err := rc.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
}
}

0 comments on commit 36ad1d9

Please sign in to comment.