Add --ignore, to skip directories
This commit is contained in:
parent
57e5b7dff2
commit
eaed4f11ef
|
@ -32,6 +32,9 @@ You can combine these two parameters, with exclusions taking priority over inclu
|
||||||
|
|
||||||
Both filtering parameters ignore the file extension and full path; they only compare against the bare filename.
|
Both filtering parameters ignore the file extension and full path; they only compare against the bare filename.
|
||||||
|
|
||||||
|
## Ignoring directories
|
||||||
|
Any directory containing a file named `.roulette_ignore` will be skipped during the scanning stage.
|
||||||
|
|
||||||
## Indexing
|
## Indexing
|
||||||
If the `-i|--indexing` flag is passed, all specified paths will be indexed on start.
|
If the `-i|--indexing` flag is passed, all specified paths will be indexed on start.
|
||||||
|
|
||||||
|
@ -124,6 +127,7 @@ Flags:
|
||||||
--fun add a bit of excitement to your day
|
--fun add a bit of excitement to your day
|
||||||
--handlers display registered handlers (for debugging)
|
--handlers display registered handlers (for debugging)
|
||||||
-h, --help help for roulette
|
-h, --help help for roulette
|
||||||
|
--ignore skip all directories containing a file named .roulette_ignore
|
||||||
--images enable support for image files
|
--images enable support for image files
|
||||||
--index generate index of supported file paths at startup
|
--index generate index of supported file paths at startup
|
||||||
--index-file string path to optional persistent index file
|
--index-file string path to optional persistent index file
|
||||||
|
|
12
cmd/files.go
12
cmd/files.go
|
@ -22,6 +22,10 @@ import (
|
||||||
"seedno.de/seednode/roulette/types"
|
"seedno.de/seednode/roulette/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ignoreFileName string = `.roulette_ignore`
|
||||||
|
)
|
||||||
|
|
||||||
type regexes struct {
|
type regexes struct {
|
||||||
alphanumeric *regexp.Regexp
|
alphanumeric *regexp.Regexp
|
||||||
filename *regexp.Regexp
|
filename *regexp.Regexp
|
||||||
|
@ -233,17 +237,23 @@ func walkPath(path string, fileChannel chan<- string, stats *scanStatsChannels,
|
||||||
|
|
||||||
var directories, files = 0, 0
|
var directories, files = 0, 0
|
||||||
|
|
||||||
|
var skipDir = false
|
||||||
|
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
if node.IsDir() {
|
if node.IsDir() {
|
||||||
directories++
|
directories++
|
||||||
} else {
|
} else {
|
||||||
|
if Ignore && node.Name() == ignoreFileName {
|
||||||
|
skipDir = true
|
||||||
|
}
|
||||||
|
|
||||||
files++
|
files++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var skipFiles = false
|
var skipFiles = false
|
||||||
|
|
||||||
if files <= MaxFileCount && files >= MinFileCount {
|
if files <= MaxFileCount && files >= MinFileCount && !skipDir {
|
||||||
stats.directoriesMatched <- 1
|
stats.directoriesMatched <- 1
|
||||||
} else {
|
} else {
|
||||||
stats.filesSkipped <- files
|
stats.filesSkipped <- files
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ReleaseVersion string = "3.2.10"
|
ReleaseVersion string = "3.3.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -29,6 +29,7 @@ var (
|
||||||
Flash bool
|
Flash bool
|
||||||
Fun bool
|
Fun bool
|
||||||
Handlers bool
|
Handlers bool
|
||||||
|
Ignore bool
|
||||||
Images bool
|
Images bool
|
||||||
Index bool
|
Index bool
|
||||||
IndexFile string
|
IndexFile string
|
||||||
|
@ -96,6 +97,7 @@ func init() {
|
||||||
rootCmd.Flags().BoolVar(&Flash, "flash", false, "enable support for shockwave flash files (via ruffle.rs)")
|
rootCmd.Flags().BoolVar(&Flash, "flash", false, "enable support for shockwave flash files (via ruffle.rs)")
|
||||||
rootCmd.Flags().BoolVar(&Fun, "fun", false, "add a bit of excitement to your day")
|
rootCmd.Flags().BoolVar(&Fun, "fun", false, "add a bit of excitement to your day")
|
||||||
rootCmd.Flags().BoolVar(&Handlers, "handlers", false, "display registered handlers (for debugging)")
|
rootCmd.Flags().BoolVar(&Handlers, "handlers", false, "display registered handlers (for debugging)")
|
||||||
|
rootCmd.Flags().BoolVar(&Ignore, "ignore", false, "skip all directories containing a file named .roulette_ignore")
|
||||||
rootCmd.Flags().BoolVar(&Images, "images", false, "enable support for image files")
|
rootCmd.Flags().BoolVar(&Images, "images", false, "enable support for image files")
|
||||||
rootCmd.Flags().BoolVar(&Index, "index", false, "generate index of supported file paths at startup")
|
rootCmd.Flags().BoolVar(&Index, "index", false, "generate index of supported file paths at startup")
|
||||||
rootCmd.Flags().StringVar(&IndexFile, "index-file", "", "path to optional persistent index file")
|
rootCmd.Flags().StringVar(&IndexFile, "index-file", "", "path to optional persistent index file")
|
||||||
|
|
Loading…
Reference in New Issue