diff --git a/cmd/entropy.go b/cmd/entropy.go index 6b84d4e..7c5a0b9 100644 --- a/cmd/entropy.go +++ b/cmd/entropy.go @@ -10,6 +10,7 @@ import ( var noBrowserOpen bool var enableGui bool +var renderPath string func EntropyCmd() *cobra.Command { cmd := &cobra.Command{ @@ -37,6 +38,7 @@ func EntropyCmd() *cobra.Command { NoOpen: noBrowserOpen, EnableGui: enableGui, LoadCallbacks: graph.NewStdErrCallbacks[*language.FileInfo](), + RenderPath: renderPath, }) return err }, @@ -44,6 +46,7 @@ func EntropyCmd() *cobra.Command { cmd.Flags().BoolVar(&noBrowserOpen, "no-browser-open", false, "Disable the automatic browser open while rendering entropy") cmd.Flags().BoolVar(&enableGui, "enable-gui", false, "Enables a GUI for changing rendering settings") + cmd.Flags().StringVar(&renderPath, "render-path", "", "Sets the output path of the rendered html file") return cmd } diff --git a/internal/entropy/render.go b/internal/entropy/render.go index 7aba886..9016988 100644 --- a/internal/entropy/render.go +++ b/internal/entropy/render.go @@ -21,6 +21,7 @@ const ReplacePrefix = "const DATA = " type RenderConfig struct { NoOpen bool EnableGui bool + RenderPath string LoadCallbacks graph.LoadCallbacks[*language.FileInfo] } @@ -35,7 +36,12 @@ func Render(files []string, parser graph.NodeParser[*language.FileInfo], cfg Ren return err } rendered := bytes.ReplaceAll(index, []byte(ToReplace), append([]byte(ReplacePrefix), marshaled...)) - temp := filepath.Join(os.TempDir(), "index.html") + var temp string + if cfg.RenderPath != "" { + temp = cfg.RenderPath + } else { + temp = filepath.Join(os.TempDir(), "index.html") + } err = os.WriteFile(temp, rendered, os.ModePerm) if err != nil { return err