Skip to content
Snippets Groups Projects
Verified Commit 4e2ab573 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

feat: add verbose flag and fix text infos

parent 1a732807
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,8 @@ import ( ...@@ -18,7 +18,8 @@ import (
) )
type Definition struct { 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"` } `command:"help" call:"PrintHelp" description:"Prints this help message"`
Template struct { Template struct {
Prepare struct { Prepare struct {
......
...@@ -2,6 +2,7 @@ package main ...@@ -2,6 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/charmbracelet/log"
xflags "gitlab.schukai.com/oss/libraries/go/application/xflags.git" xflags "gitlab.schukai.com/oss/libraries/go/application/xflags.git"
"os" "os"
...@@ -14,8 +15,16 @@ func main() { ...@@ -14,8 +15,16 @@ func main() {
definition := Definition{} definition := Definition{}
definition.Template.Prepare.DataFile = "data.yaml" definition.Template.Prepare.DataFile = "data.yaml"
logger := log.Default()
logger.SetLevel(log.ErrorLevel)
settings = xflags.New(os.Args[0], definition) settings = xflags.New(os.Args[0], definition)
settings.Parse(os.Args[1:]) settings.Parse(os.Args[1:])
if settings.GetValues().Verbose {
logger.SetLevel(log.DebugLevel)
}
settings.Execute() settings.Execute()
if settings.HasErrors() { if settings.HasErrors() {
......
...@@ -413,6 +413,7 @@ func removeDuplicateWhitespaces(str string) string { ...@@ -413,6 +413,7 @@ func removeDuplicateWhitespaces(str string) string {
func handleTextNode(n *html.Node, storage *types.PageData) { func handleTextNode(n *html.Node, storage *types.PageData) {
content := strings.TrimSpace(n.Data) content := strings.TrimSpace(n.Data)
if content == "" { if content == "" {
return return
} }
...@@ -425,6 +426,15 @@ func handleTextNode(n *html.Node, storage *types.PageData) { ...@@ -425,6 +426,15 @@ func handleTextNode(n *html.Node, storage *types.PageData) {
// if span and has constants.DataBobReferenceAttributeKey, ignore // if span and has constants.DataBobReferenceAttributeKey, ignore
if n.Parent.Data == "span" && util.HasAttribute(n.Parent.Attr, constants.DataBobReferenceAttributeKey) { 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 return
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment