Simplify type registration system

This commit is contained in:
Seednode 2023-09-29 14:36:11 -05:00
parent 71497198fa
commit fa1e3d126f
8 changed files with 13 additions and 39 deletions

View File

@ -12,7 +12,7 @@ import (
)
const (
ReleaseVersion string = "2.0.2"
ReleaseVersion string = "2.0.3"
)
var (

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)

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{})
}