All arguments are now at most two hyphenated words

This commit is contained in:
Seednode 2024-02-06 16:10:06 -06:00
parent 9989b42386
commit 065cb275ae
4 changed files with 18 additions and 18 deletions

View File

@ -258,7 +258,7 @@ func walkPath(path string, fileChannel chan<- string, wg1 *sync.WaitGroup, stats
var skipFiles = false var skipFiles = false
if files > MaxFileCount || files < MinFileCount || skipDir { if files > MaxFiles || files < MinFiles || skipDir {
stats.filesSkipped <- files stats.filesSkipped <- files
stats.directoriesSkipped <- 1 stats.directoriesSkipped <- 1

View File

@ -17,7 +17,7 @@ import (
const ( const (
AllowedCharacters string = `^[A-z0-9.\-_]+$` AllowedCharacters string = `^[A-z0-9.\-_]+$`
ReleaseVersion string = "8.5.2" ReleaseVersion string = "8.6.0"
) )
var ( var (
@ -32,8 +32,7 @@ var (
CodeTheme string CodeTheme string
Concurrency int Concurrency int
Debug bool Debug bool
DisableButtons bool ErrorExit bool
ExitOnError bool
Fallback bool Fallback bool
Filtering bool Filtering bool
Flash bool Flash bool
@ -43,8 +42,9 @@ var (
Index bool Index bool
IndexFile string IndexFile string
IndexInterval string IndexInterval string
MaxFileCount int MaxFiles int
MinFileCount int MinFiles int
NoButtons bool
Port int Port int
Prefix string Prefix string
Profile bool Profile bool
@ -74,9 +74,9 @@ var (
Args: cobra.MinimumNArgs(1), Args: cobra.MinimumNArgs(1),
PreRunE: func(cmd *cobra.Command, args []string) error { PreRunE: func(cmd *cobra.Command, args []string) error {
switch { 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 return ErrInvalidFileCountValue
case MinFileCount > MaxFileCount: case MinFiles > MaxFiles:
return ErrInvalidFileCountRange return ErrInvalidFileCountRange
case Port < 1 || Port > 65535: case Port < 1 || Port > 65535:
return ErrInvalidPort return ErrInvalidPort
@ -124,8 +124,7 @@ func init() {
rootCmd.Flags().StringVar(&CodeTheme, "code-theme", "solarized-dark256", "theme for source code syntax highlighting") 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().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().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(&ErrorExit, "error-exit", false, "shut down webserver on error, instead of just printing error")
rootCmd.Flags().BoolVar(&ExitOnError, "exit-on-error", 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().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().BoolVarP(&Filtering, "filter", "f", false, "enable filtering")
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)")
@ -135,8 +134,9 @@ func init() {
rootCmd.Flags().BoolVarP(&Index, "index", "i", false, "generate index of supported file paths at startup") 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(&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().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(&MaxFiles, "max-files", 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(&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().IntVarP(&Port, "port", "p", 8080, "port to listen on")
rootCmd.Flags().StringVar(&Prefix, "prefix", "/", "root path for http handlers (for reverse proxying)") rootCmd.Flags().StringVar(&Prefix, "prefix", "/", "root path for http handlers (for reverse proxying)")
rootCmd.Flags().BoolVar(&Profile, "profile", false, "register net/http/pprof handlers") rootCmd.Flags().BoolVar(&Profile, "profile", false, "register net/http/pprof handlers")

View File

@ -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) paginated, err := paginate(path, first, last, queryParams, filename, formats)
if err != nil { if err != nil {
errorChannel <- err errorChannel <- err
@ -512,7 +512,7 @@ func ServePage(args []string) error {
} }
if Images || All { if Images || All {
formats.Add(images.Format{DisableButtons: DisableButtons, Fun: Fun}) formats.Add(images.Format{NoButtons: NoButtons, Fun: Fun})
} }
paths, err := validatePaths(args, formats) paths, err := validatePaths(args, formats)
@ -548,7 +548,7 @@ func ServePage(args []string) error {
go func() { go func() {
for err := range errorChannel { for err := range errorChannel {
switch { switch {
case ExitOnError: case ErrorExit:
fmt.Printf("%s | FATAL: %v\n", time.Now().Format(logDate), err) fmt.Printf("%s | FATAL: %v\n", time.Now().Format(logDate), err)
case Debug && errors.Is(err, os.ErrNotExist) || errors.Is(err, os.ErrPermission): case Debug && errors.Is(err, os.ErrNotExist) || errors.Is(err, os.ErrPermission):
fmt.Printf("%s | DEBUG: %v\n", time.Now().Format(logDate), err) fmt.Printf("%s | DEBUG: %v\n", time.Now().Format(logDate), err)

View File

@ -27,8 +27,8 @@ type dimensions struct {
} }
type Format struct { type Format struct {
DisableButtons bool NoButtons bool
Fun bool Fun bool
} }
func (t Format) CSP(w http.ResponseWriter) string { func (t Format) CSP(w http.ResponseWriter) string {
@ -43,7 +43,7 @@ func (t Format) CSS() string {
var css strings.Builder var css strings.Builder
css.WriteString(`html,body{margin:0;padding:0;height:100%;}`) 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;}`) css.WriteString(`a{color:inherit;display:block;height:100%;width:100%;text-decoration:none;}`)
} else { } else {
css.WriteString(`a{color:inherit;display:block;height:97%;width:100%;text-decoration:none;}`) css.WriteString(`a{color:inherit;display:block;height:97%;width:100%;text-decoration:none;}`)