From bb9d4596b4ac624fd44822e698e537dd0babd705 Mon Sep 17 00:00:00 2001 From: Konstantin Nezhbert Date: Thu, 21 Nov 2024 12:59:43 +0300 Subject: [PATCH] feat(backend): Added the dry-run flag for the LaTeX generation (#34) --- cmd/common/common.go | 1 + cmd/root/root.go | 1 + internal/latex_service/latex.go | 9 +++++---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/common/common.go b/cmd/common/common.go index 7e6a64d..af7b230 100644 --- a/cmd/common/common.go +++ b/cmd/common/common.go @@ -35,4 +35,5 @@ type ColligendisFlags struct { SortType string ViewMode bool Limit int + DryRun bool } diff --git a/cmd/root/root.go b/cmd/root/root.go index d8818db..f990d2b 100644 --- a/cmd/root/root.go +++ b/cmd/root/root.go @@ -58,6 +58,7 @@ func createRootCommand(flags *common.ColligendisFlags, tmpls []structs.TemplateS cmd.AddCommand(convert.GetConvertCommand(flags, tmpls)) cmd.PersistentFlags().BoolVarP(&flags.ViewMode, "verbose", "v", false, "Show the full report of the commands") + cmd.PersistentFlags().BoolVarP(&flags.DryRun, "dry-run", "", false, "Start command without real generation") return cmd } diff --git a/internal/latex_service/latex.go b/internal/latex_service/latex.go index 4707400..1089b68 100644 --- a/internal/latex_service/latex.go +++ b/internal/latex_service/latex.go @@ -39,10 +39,11 @@ func GenerateLaTeXFiles(tmpls []structs.TemplateStruct, flags *common.Colligendi log.Printf("Unable to create file: %w", err) } - generatePDF(flags) - generatePDF(flags) - - copyFile(templateData.LatestDate) + if !flags.DryRun { + generatePDF(flags) + generatePDF(flags) + copyFile(templateData.LatestDate) + } } func getHabrData() structs.TemplateData {