diff --git a/source/command.go b/source/command.go index 20bd3ea6439166ae7e81abdf85403b28409fb475..bd88abe9a631282ceeff1ba76be759f40ccdf9de 100644 --- a/source/command.go +++ b/source/command.go @@ -18,7 +18,8 @@ import ( ) type Definition struct { - Help struct { + Verbose bool `short:"v" long:"verbose" description:"Show verbose debug information"` + Help struct { } `command:"help" call:"PrintHelp" description:"Prints this help message"` Template struct { Prepare struct { diff --git a/source/main.go b/source/main.go index c9e634bec0cc98ff48527ff9e720755b8d2b1d59..fa3146351b8717d7220504742a2eefb9f8e5ab4c 100644 --- a/source/main.go +++ b/source/main.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "github.com/charmbracelet/log" xflags "gitlab.schukai.com/oss/libraries/go/application/xflags.git" "os" @@ -14,8 +15,16 @@ func main() { definition := Definition{} definition.Template.Prepare.DataFile = "data.yaml" + logger := log.Default() + logger.SetLevel(log.ErrorLevel) + settings = xflags.New(os.Args[0], definition) settings.Parse(os.Args[1:]) + + if settings.GetValues().Verbose { + logger.SetLevel(log.DebugLevel) + } + settings.Execute() if settings.HasErrors() { diff --git a/source/template/prepare.go b/source/template/prepare.go index de3624cb9c714b85c39d98ed70194a28e621d410..c50fa1f14353f31b269d5ab09f4ff5aa9631a523 100644 --- a/source/template/prepare.go +++ b/source/template/prepare.go @@ -413,6 +413,7 @@ func removeDuplicateWhitespaces(str string) string { func handleTextNode(n *html.Node, storage *types.PageData) { content := strings.TrimSpace(n.Data) + if content == "" { return } @@ -425,6 +426,15 @@ func handleTextNode(n *html.Node, storage *types.PageData) { // if span and has constants.DataBobReferenceAttributeKey, ignore if n.Parent.Data == "span" && util.HasAttribute(n.Parent.Attr, constants.DataBobReferenceAttributeKey) { + + id := util.GetAttribute(n.Parent.Attr, constants.DataBobReferenceAttributeKey) + + log.Info("Added text: " + id + " (" + logContent + ") to storage") + storage.Text = append(storage.Text, types.Text{ + Id: id, + Text: content, + }) + return }