All arguments are now at most two hyphenated words
This commit is contained in:
parent
9989b42386
commit
065cb275ae
|
@ -258,7 +258,7 @@ func walkPath(path string, fileChannel chan<- string, wg1 *sync.WaitGroup, stats
|
|||
|
||||
var skipFiles = false
|
||||
|
||||
if files > MaxFileCount || files < MinFileCount || skipDir {
|
||||
if files > MaxFiles || files < MinFiles || skipDir {
|
||||
stats.filesSkipped <- files
|
||||
stats.directoriesSkipped <- 1
|
||||
|
||||
|
|
22
cmd/root.go
22
cmd/root.go
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
const (
|
||||
AllowedCharacters string = `^[A-z0-9.\-_]+$`
|
||||
ReleaseVersion string = "8.5.2"
|
||||
ReleaseVersion string = "8.6.0"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -32,8 +32,7 @@ var (
|
|||
CodeTheme string
|
||||
Concurrency int
|
||||
Debug bool
|
||||
DisableButtons bool
|
||||
ExitOnError bool
|
||||
ErrorExit bool
|
||||
Fallback bool
|
||||
Filtering bool
|
||||
Flash bool
|
||||
|
@ -43,8 +42,9 @@ var (
|
|||
Index bool
|
||||
IndexFile string
|
||||
IndexInterval string
|
||||
MaxFileCount int
|
||||
MinFileCount int
|
||||
MaxFiles int
|
||||
MinFiles int
|
||||
NoButtons bool
|
||||
Port int
|
||||
Prefix string
|
||||
Profile bool
|
||||
|
@ -74,9 +74,9 @@ var (
|
|||
Args: cobra.MinimumNArgs(1),
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
switch {
|
||||
case MaxFileCount < 0 || MinFileCount < 0 || MaxFileCount > math.MaxInt32 || MinFileCount > math.MaxInt32:
|
||||
case MaxFiles < 0 || MinFiles < 0 || MaxFiles > math.MaxInt32 || MinFiles > math.MaxInt32:
|
||||
return ErrInvalidFileCountValue
|
||||
case MinFileCount > MaxFileCount:
|
||||
case MinFiles > MaxFiles:
|
||||
return ErrInvalidFileCountRange
|
||||
case Port < 1 || Port > 65535:
|
||||
return ErrInvalidPort
|
||||
|
@ -124,8 +124,7 @@ func init() {
|
|||
rootCmd.Flags().StringVar(&CodeTheme, "code-theme", "solarized-dark256", "theme for source code syntax highlighting")
|
||||
rootCmd.Flags().IntVar(&Concurrency, "concurrency", 1024, "maximum concurrency for scan threads")
|
||||
rootCmd.Flags().BoolVarP(&Debug, "debug", "d", false, "log file permission errors instead of simply skipping the files")
|
||||
rootCmd.Flags().BoolVar(&DisableButtons, "disable-buttons", false, "disable first/prev/next/last buttons")
|
||||
rootCmd.Flags().BoolVar(&ExitOnError, "exit-on-error", false, "shut down webserver on error, instead of just printing error")
|
||||
rootCmd.Flags().BoolVar(&ErrorExit, "error-exit", false, "shut down webserver on error, instead of just printing error")
|
||||
rootCmd.Flags().BoolVar(&Fallback, "fallback", false, "serve files as application/octet-stream if no matching format is registered")
|
||||
rootCmd.Flags().BoolVarP(&Filtering, "filter", "f", false, "enable filtering")
|
||||
rootCmd.Flags().BoolVar(&Flash, "flash", false, "enable support for shockwave flash files (via ruffle.rs)")
|
||||
|
@ -135,8 +134,9 @@ func init() {
|
|||
rootCmd.Flags().BoolVarP(&Index, "index", "i", false, "generate index of supported file paths at startup")
|
||||
rootCmd.Flags().StringVar(&IndexFile, "index-file", "", "path to optional persistent index file")
|
||||
rootCmd.Flags().StringVar(&IndexInterval, "index-interval", "", "interval at which to regenerate index (e.g. \"5m\" or \"1h\")")
|
||||
rootCmd.Flags().IntVar(&MaxFileCount, "max-file-count", math.MaxInt32, "skip directories with file counts above this value")
|
||||
rootCmd.Flags().IntVar(&MinFileCount, "min-file-count", 0, "skip directories with file counts below this value")
|
||||
rootCmd.Flags().IntVar(&MaxFiles, "max-files", math.MaxInt32, "skip directories with file counts above this value")
|
||||
rootCmd.Flags().IntVar(&MinFiles, "min-files", 0, "skip directories with file counts below this value")
|
||||
rootCmd.Flags().BoolVar(&NoButtons, "no-buttons", false, "disable first/prev/next/last buttons")
|
||||
rootCmd.Flags().IntVarP(&Port, "port", "p", 8080, "port to listen on")
|
||||
rootCmd.Flags().StringVar(&Prefix, "prefix", "/", "root path for http handlers (for reverse proxying)")
|
||||
rootCmd.Flags().BoolVar(&Profile, "profile", false, "register net/http/pprof handlers")
|
||||
|
|
|
@ -357,7 +357,7 @@ func serveMedia(paths []string, index *fileIndex, filename *regexp.Regexp, forma
|
|||
}
|
||||
}
|
||||
|
||||
if Index && !DisableButtons && sortOrder != "" {
|
||||
if Index && !NoButtons && sortOrder != "" {
|
||||
paginated, err := paginate(path, first, last, queryParams, filename, formats)
|
||||
if err != nil {
|
||||
errorChannel <- err
|
||||
|
@ -512,7 +512,7 @@ func ServePage(args []string) error {
|
|||
}
|
||||
|
||||
if Images || All {
|
||||
formats.Add(images.Format{DisableButtons: DisableButtons, Fun: Fun})
|
||||
formats.Add(images.Format{NoButtons: NoButtons, Fun: Fun})
|
||||
}
|
||||
|
||||
paths, err := validatePaths(args, formats)
|
||||
|
@ -548,7 +548,7 @@ func ServePage(args []string) error {
|
|||
go func() {
|
||||
for err := range errorChannel {
|
||||
switch {
|
||||
case ExitOnError:
|
||||
case ErrorExit:
|
||||
fmt.Printf("%s | FATAL: %v\n", time.Now().Format(logDate), err)
|
||||
case Debug && errors.Is(err, os.ErrNotExist) || errors.Is(err, os.ErrPermission):
|
||||
fmt.Printf("%s | DEBUG: %v\n", time.Now().Format(logDate), err)
|
||||
|
|
|
@ -27,7 +27,7 @@ type dimensions struct {
|
|||
}
|
||||
|
||||
type Format struct {
|
||||
DisableButtons bool
|
||||
NoButtons bool
|
||||
Fun bool
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ func (t Format) CSS() string {
|
|||
var css strings.Builder
|
||||
|
||||
css.WriteString(`html,body{margin:0;padding:0;height:100%;}`)
|
||||
if t.DisableButtons {
|
||||
if t.NoButtons {
|
||||
css.WriteString(`a{color:inherit;display:block;height:100%;width:100%;text-decoration:none;}`)
|
||||
} else {
|
||||
css.WriteString(`a{color:inherit;display:block;height:97%;width:100%;text-decoration:none;}`)
|
||||
|
|
Loading…
Reference in New Issue