From 21cf51efd78861a120f6b712124fb3db2d503e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Mon, 20 Mar 2023 19:56:02 +0100 Subject: [PATCH] Clean up logic a bit --- main.go | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/main.go b/main.go index c6a0786..c59c9e2 100644 --- a/main.go +++ b/main.go @@ -196,29 +196,21 @@ func processFile( } if pageID == "" && meta == nil { - if flags.TitleFromH1 && flags.Space != "" { - meta = &mark.Meta{} - meta.Type = "page" - } else { - log.Fatal( - `specified file doesn't contain metadata ` + - `and URL is not specified via command line ` + - `or doesn't contain pageId GET-parameter`, - ) - } - } - - switch { - case meta.Space == "" && flags.Space == "": log.Fatal( - "space is not set ('Space' header is not set and '--space' option is not set)", + `specified file doesn't contain metadata ` + + `and URL is not specified via command line ` + + `or doesn't contain pageId GET-parameter`, ) - case meta.Space == "" && flags.Space != "": - meta.Space = flags.Space } - if meta.Title == "" && flags.TitleFromH1 { - meta.Title = mark.ExtractDocumentLeadingH1(markdown) + if meta.Space == "" { + if flags.Space == "" { + log.Fatal( + "space is not set ('Space' header is not set and '--space' option is not set)", + ) + } else { + meta.Space = flags.Space + } } if meta.Title == "" {