From 076165c1373c142b5ea62535375e94297b65c8a8 Mon Sep 17 00:00:00 2001 From: iyz Date: Mon, 17 Feb 2025 15:31:53 -0500 Subject: [PATCH] return nil instead of exiting, check for nil in loop --- main.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index f532e41..db9ca01 100644 --- a/main.go +++ b/main.go @@ -286,13 +286,15 @@ func RunMark(cCtx *cli.Context) error { target := processFile(file, api, cCtx, creds.PageID, creds.Username) - log.Infof( - nil, - "page successfully updated: %s", - creds.BaseURL+target.Links.Full, - ) - - fmt.Println(creds.BaseURL + target.Links.Full) + if target != nil { // on dry-run or compile-only, the target is nil + log.Infof( + nil, + "page successfully updated: %s", + creds.BaseURL+target.Links.Full, + ) + + fmt.Println(creds.BaseURL + target.Links.Full) + } } return nil } @@ -415,7 +417,7 @@ func processFile( html, _ := mark.CompileMarkdown(markdown, stdlib, file, cCtx.String("mermaid-provider"), cCtx.Float64("mermaid-scale"), cCtx.Bool("drop-h1"), cCtx.Bool("strip-linebreaks")) fmt.Println(html) - os.Exit(0) + return nil } var target *confluence.PageInfo