2022-09-08 15:12:06 +00:00
|
|
|
/*
|
|
|
|
Copyright © 2022 Seednode <seednode@seedno.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2022-09-09 00:02:33 +00:00
|
|
|
"fmt"
|
2022-09-08 15:12:06 +00:00
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var Port int
|
|
|
|
var Recursive bool
|
2022-09-09 00:02:33 +00:00
|
|
|
var Verbose bool
|
2022-09-08 15:12:06 +00:00
|
|
|
|
|
|
|
var rootCmd = &cobra.Command{
|
|
|
|
Use: "roulette <path1> [path2] ... [pathN]",
|
|
|
|
Short: "Serves random images from the specified directories.",
|
2022-09-08 15:57:59 +00:00
|
|
|
Args: cobra.MinimumNArgs(1),
|
2022-09-08 15:12:06 +00:00
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2022-09-08 15:57:59 +00:00
|
|
|
ServePage(args)
|
2022-09-08 15:12:06 +00:00
|
|
|
},
|
|
|
|
Version: Version,
|
|
|
|
}
|
|
|
|
|
|
|
|
func Execute() {
|
|
|
|
err := rootCmd.Execute()
|
|
|
|
if err != nil {
|
2022-09-09 00:02:33 +00:00
|
|
|
fmt.Println(err)
|
|
|
|
panic(Exit{1})
|
2022-09-08 15:12:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
rootCmd.Flags().IntVarP(&Port, "port", "p", 8080, "port to listen on")
|
|
|
|
rootCmd.Flags().BoolVarP(&Recursive, "recursive", "r", false, "recurse into subdirectories")
|
2022-09-09 00:02:33 +00:00
|
|
|
rootCmd.Flags().BoolVarP(&Verbose, "verbose", "v", false, "also write output to stdout")
|
2022-09-08 15:12:06 +00:00
|
|
|
rootCmd.Flags().SetInterspersed(false)
|
|
|
|
}
|