From fa1e3d126f148f19f9888fb14a41be577ef1878b Mon Sep 17 00:00:00 2001 From: Seednode Date: Fri, 29 Sep 2023 14:36:11 -0500 Subject: [PATCH] Simplify type registration system --- cmd/root.go | 2 +- cmd/web.go | 12 ++++++------ types/audio/audio.go | 6 +----- types/code/code.go | 8 +------- types/flash/flash.go | 6 +----- types/images/images.go | 6 +----- types/text/text.go | 6 +----- types/video/video.go | 6 +----- 8 files changed, 13 insertions(+), 39 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index ca74ad9..d9389fe 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,7 +12,7 @@ import ( ) const ( - ReleaseVersion string = "2.0.2" + ReleaseVersion string = "2.0.3" ) var ( diff --git a/cmd/web.go b/cmd/web.go index 47f121e..8239d03 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -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) diff --git a/types/audio/audio.go b/types/audio/audio.go index 8a46da7..e699f0e 100644 --- a/types/audio/audio.go +++ b/types/audio/audio.go @@ -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{}) } diff --git a/types/code/code.go b/types/code/code.go index e40e58c..c4fd9e0 100644 --- a/types/code/code.go +++ b/types/code/code.go @@ -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{}) } diff --git a/types/flash/flash.go b/types/flash/flash.go index 5a360fb..77ecbc1 100644 --- a/types/flash/flash.go +++ b/types/flash/flash.go @@ -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{}) } diff --git a/types/images/images.go b/types/images/images.go index dc5e24d..9c5a108 100644 --- a/types/images/images.go +++ b/types/images/images.go @@ -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{}) } diff --git a/types/text/text.go b/types/text/text.go index 24020ad..914b2f8 100644 --- a/types/text/text.go +++ b/types/text/text.go @@ -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{}) } diff --git a/types/video/video.go b/types/video/video.go index 7fca6bf..17e2607 100644 --- a/types/video/video.go +++ b/types/video/video.go @@ -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{}) }