Added handling for errors so it doesn't just silently exit if the port is in use

This commit is contained in:
Seednode 2022-10-19 20:07:20 -05:00
parent f2204a3019
commit 7819cf3090
2 changed files with 7 additions and 2 deletions

View File

@ -5,6 +5,7 @@ Copyright © 2022 Seednode <seednode@seedno.de>
package cmd package cmd
import ( import (
"fmt"
"os" "os"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -19,7 +20,11 @@ var rootCmd = &cobra.Command{
Short: "Serves random images from the specified directories.", Short: "Serves random images from the specified directories.",
Args: cobra.MinimumNArgs(1), Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
ServePage(args) err := ServePage(args)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}, },
} }

View File

@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var Version = "0.14.1" var Version = "0.14.2"
func init() { func init() {
rootCmd.AddCommand(versionCmd) rootCmd.AddCommand(versionCmd)