Clean up logic a bit

This commit is contained in:
Manuel Rüger 2023-03-20 19:56:02 +01:00
parent 20d3d1f05c
commit 21cf51efd7

14
main.go
View File

@ -196,29 +196,21 @@ func processFile(
} }
if pageID == "" && meta == nil { if pageID == "" && meta == nil {
if flags.TitleFromH1 && flags.Space != "" {
meta = &mark.Meta{}
meta.Type = "page"
} else {
log.Fatal( log.Fatal(
`specified file doesn't contain metadata ` + `specified file doesn't contain metadata ` +
`and URL is not specified via command line ` + `and URL is not specified via command line ` +
`or doesn't contain pageId GET-parameter`, `or doesn't contain pageId GET-parameter`,
) )
} }
}
switch { if meta.Space == "" {
case meta.Space == "" && flags.Space == "": if flags.Space == "" {
log.Fatal( log.Fatal(
"space is not set ('Space' header is not set and '--space' option is not set)", "space is not set ('Space' header is not set and '--space' option is not set)",
) )
case meta.Space == "" && flags.Space != "": } else {
meta.Space = flags.Space meta.Space = flags.Space
} }
if meta.Title == "" && flags.TitleFromH1 {
meta.Title = mark.ExtractDocumentLeadingH1(markdown)
} }
if meta.Title == "" { if meta.Title == "" {