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

30
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(
`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( 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 { if meta.Space == "" {
meta.Title = mark.ExtractDocumentLeadingH1(markdown) 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 == "" { if meta.Title == "" {