Set --cache and --filter as mutually exclusive

This commit is contained in:
Seednode 2022-10-28 22:59:59 -05:00
parent 3d6e7b0493
commit 2274c51e84
3 changed files with 6 additions and 5 deletions

View File

@ -60,8 +60,8 @@ Available Commands:
version Print version version Print version
Flags: Flags:
-c, --cache only scan directories once, at startup -c, --cache only scan directories once, at startup (incompatible with --filter)
-f, --filter enable filtering via query parameters -f, --filter enable filtering via query parameters (incompatible with --cache)
-h, --help help for roulette -h, --help help for roulette
-p, --port uint16 port to listen on (default 8080) -p, --port uint16 port to listen on (default 8080)
-r, --recursive recurse into subdirectories -r, --recursive recurse into subdirectories

View File

@ -55,8 +55,9 @@ func Execute() {
} }
func init() { func init() {
rootCmd.Flags().BoolVarP(&Cache, "cache", "c", false, "only scan directories once, at startup") rootCmd.Flags().BoolVarP(&Cache, "cache", "c", false, "only scan directories once, at startup (incompatible with --filter)")
rootCmd.Flags().BoolVarP(&Filter, "filter", "f", false, "enable filtering via query parameters") rootCmd.Flags().BoolVarP(&Filter, "filter", "f", false, "enable filtering via query parameters (incompatible with --cache)")
rootCmd.MarkFlagsMutuallyExclusive("cache", "filter")
rootCmd.Flags().Uint16VarP(&Port, "port", "p", 8080, "port to listen on") rootCmd.Flags().Uint16VarP(&Port, "port", "p", 8080, "port to listen on")
rootCmd.Flags().BoolVarP(&Recursive, "recursive", "r", false, "recurse into subdirectories") rootCmd.Flags().BoolVarP(&Recursive, "recursive", "r", false, "recurse into subdirectories")
rootCmd.Flags().BoolVarP(&Sort, "sort", "s", false, "enable sorting via query parameters") rootCmd.Flags().BoolVarP(&Sort, "sort", "s", false, "enable sorting via query parameters")

View File

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