Removed mutually exclusive flag from cache and filter, now cache is bypassed if filters are supplied

This commit is contained in:
Seednode 2023-01-18 11:50:29 -06:00
parent b5c4534151
commit b96ee8ac99
4 changed files with 6 additions and 7 deletions

View File

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

View File

@ -482,7 +482,7 @@ func prepareDirectories(files *Files, sort string) []string {
func pickFile(args []string, filters *Filters, sort string, fileCache *[]string) (string, error) {
var fileList []string
if Cache && len(*fileCache) != 0 {
if Cache && filters.IsEmpty() && len(*fileCache) != 0 {
fileList = *fileCache
} else {
files := &Files{

View File

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

View File

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