roulette/cmd/root.go

41 lines
921 B
Go
Raw Normal View History

2022-09-08 15:12:06 +00:00
/*
Copyright © 2022 Seednode <seednode@seedno.de>
*/
package cmd
import (
2022-09-10 21:35:05 +00:00
"os"
2022-09-08 15:12:06 +00:00
"github.com/spf13/cobra"
)
var Port int
var Recursive bool
var Successive bool
var Verbose bool
2022-09-08 15:12:06 +00:00
var rootCmd = &cobra.Command{
2022-09-16 19:57:40 +00:00
Use: "roulette <path> [path2]...",
2022-09-08 15:12:06 +00:00
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
},
}
func Execute() {
err := rootCmd.Execute()
if err != nil {
2022-09-10 21:35:05 +00:00
os.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")
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)
2022-09-08 15:12:06 +00:00
}