roulette/cmd/root.go

43 lines
1.0 KiB
Go

/*
Copyright © 2022 Seednode <seednode@seedno.de>
*/
package cmd
import (
"os"
"github.com/spf13/cobra"
)
var Filter string
var Port int
var Recursive bool
var Successive bool
var Verbose bool
var rootCmd = &cobra.Command{
Use: "roulette <path> [path2]...",
Short: "Serves random images from the specified directories.",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
ServePage(args)
},
}
func Execute() {
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}
func init() {
rootCmd.Flags().StringVarP(&Filter, "filter", "f", "", "only display images matching specified pattern (case-insensitive)")
rootCmd.Flags().IntVarP(&Port, "port", "p", 8080, "port to listen on")
rootCmd.Flags().BoolVarP(&Recursive, "recursive", "r", false, "recurse into subdirectories")
rootCmd.Flags().BoolVarP(&Successive, "successive", "s", false, "load the next sequential file, if possible")
rootCmd.Flags().BoolVarP(&Verbose, "verbose", "v", false, "log accessed files to stdout")
rootCmd.Flags().SetInterspersed(true)
}