Compare commits

...

2 Commits

Author SHA1 Message Date
Seednode fa1e3d126f Simplify type registration system 2023-09-29 14:36:11 -05:00
Seednode 71497198fa Remove -c shorthand for --index, update PGO profile 2023-09-29 08:31:35 -05:00
10 changed files with 20 additions and 46 deletions

View File

@ -398,7 +398,7 @@ Poll:
}
if Verbose {
fmt.Printf("%s | INDEX: Selected %d/%d files across %d/%d directories in %s\n",
fmt.Printf("%s | INDEX: Selecting from %d/%d files across %d/%d directories in %s\n",
time.Now().Format(logDate),
stats.filesMatched,
stats.filesMatched+stats.filesSkipped,

View File

@ -12,7 +12,7 @@ import (
)
const (
ReleaseVersion string = "2.0.1"
ReleaseVersion string = "2.0.3"
)
var (
@ -95,7 +95,7 @@ func init() {
rootCmd.Flags().BoolVar(&Flash, "flash", false, "enable support for shockwave flash files (via ruffle.rs)")
rootCmd.Flags().BoolVar(&Handlers, "handlers", false, "display registered handlers (for debugging)")
rootCmd.Flags().BoolVar(&Images, "images", false, "enable support for image files")
rootCmd.Flags().BoolVarP(&Index, "index", "c", 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().BoolVarP(&Info, "info", "i", false, "expose informational endpoints")
rootCmd.Flags().IntVar(&MaxDirScans, "max-directory-scans", 32, "number of directories to scan at once")

View File

@ -416,29 +416,29 @@ func ServePage(args []string) error {
}
if Audio || All {
formats.Add(audio.New())
formats.Add(audio.Format{})
}
if Code || All {
formats.Add(code.New(CodeTheme))
formats.Add(code.Format{Theme: CodeTheme})
}
if Flash || All {
formats.Add(flash.New())
formats.Add(flash.Format{})
}
if Text || All {
formats.Add(text.New())
formats.Add(text.Format{})
}
if Videos || All {
formats.Add(video.New())
formats.Add(video.Format{})
}
// enable image support if no other flags are passed, to retain backwards compatibility
// to be replaced with rootCmd.MarkFlagsOneRequired on next spf13/cobra update
if Images || All || len(formats.Extensions) == 0 {
formats.Add(images.New())
formats.Add(images.Format{})
}
paths, err := validatePaths(args, formats)
@ -503,6 +503,11 @@ func ServePage(args []string) error {
if err != nil {
return err
}
err = importIndex(paths, index, formats)
if err != nil {
return err
}
}
if Info {
@ -517,11 +522,6 @@ func ServePage(args []string) error {
fmt.Printf("WARNING! Files *will* be deleted after serving!\n\n")
}
err = importIndex(paths, index, formats)
if err != nil {
return err
}
go func() {
for err := range errorChannel {
fmt.Printf("%s | ERROR: %v\n", time.Now().Format(logDate), err)

Binary file not shown.

View File

@ -61,10 +61,6 @@ func (t Format) Type() string {
return "embed"
}
func New() Format {
return Format{}
}
func init() {
types.SupportedFormats.Register(New())
types.SupportedFormats.Register(Format{})
}

View File

@ -225,12 +225,6 @@ func (t Format) Type() string {
return "inline"
}
func New(theme string) Format {
return Format{
Theme: theme,
}
}
func init() {
types.SupportedFormats.Register(New(""))
types.SupportedFormats.Register(Format{})
}

View File

@ -60,10 +60,6 @@ func (t Format) Type() string {
return "embed"
}
func New() Format {
return Format{}
}
func init() {
types.SupportedFormats.Register(New())
types.SupportedFormats.Register(Format{})
}

View File

@ -124,10 +124,6 @@ func (t Format) Type() string {
return "embed"
}
func New() Format {
return Format{}
}
func init() {
types.SupportedFormats.Register(New())
types.SupportedFormats.Register(Format{})
}

View File

@ -80,10 +80,6 @@ func (t Format) Type() string {
return "inline"
}
func New() Format {
return Format{}
}
func init() {
types.SupportedFormats.Register(New())
types.SupportedFormats.Register(Format{})
}

View File

@ -67,10 +67,6 @@ func (t Format) Type() string {
return "embed"
}
func New() Format {
return Format{}
}
func init() {
types.SupportedFormats.Register(New())
types.SupportedFormats.Register(Format{})
}