Fix output formatting + gofmt
This commit is contained in:
parent
f309c62d5a
commit
44e58de30a
14
main.go
14
main.go
@ -45,6 +45,10 @@ Output types:
|
|||||||
os.Exit(exitStatus)
|
os.Exit(exitStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func clearLine() {
|
||||||
|
fmt.Print("\033[2K")
|
||||||
|
}
|
||||||
|
|
||||||
func printInfo(f string, v ...interface{}) {
|
func printInfo(f string, v ...interface{}) {
|
||||||
fmt.Printf("* "+f+"\n", v...)
|
fmt.Printf("* "+f+"\n", v...)
|
||||||
}
|
}
|
||||||
@ -272,7 +276,8 @@ func (e *Extractor) parseAdditionalPage(doc *gq.Document) error {
|
|||||||
ret = processChildren()
|
ret = processChildren()
|
||||||
case atom.Img:
|
case atom.Img:
|
||||||
default:
|
default:
|
||||||
printWarn("Unknown data atom:", n.Data)
|
clearLine()
|
||||||
|
printWarn("Unknown data atom: %v", n.Data)
|
||||||
}
|
}
|
||||||
// Add some CSS effects.
|
// Add some CSS effects.
|
||||||
if hasClass("spaced") {
|
if hasClass("spaced") {
|
||||||
@ -289,7 +294,8 @@ func (e *Extractor) parseAdditionalPage(doc *gq.Document) error {
|
|||||||
ret = newRet
|
ret = newRet
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
printWarn("Unknown type:", n.Type)
|
clearLine()
|
||||||
|
printWarn("Unknown type: %v", n.Type)
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
@ -382,7 +388,8 @@ func main() {
|
|||||||
|
|
||||||
// Download the actual chapters.
|
// Download the actual chapters.
|
||||||
for i, chapter := range e.ChapterUrls {
|
for i, chapter := range e.ChapterUrls {
|
||||||
fmt.Printf("\033[2K* Downloading chapter %v/%v...\r", i+1, len(e.ChapterUrls))
|
clearLine()
|
||||||
|
fmt.Printf("* Downloading chapter %v/%v...\r", i+1, len(e.ChapterUrls))
|
||||||
err = e.FetchAndProcessChapter(chapter)
|
err = e.FetchAndProcessChapter(chapter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -392,5 +399,6 @@ func main() {
|
|||||||
// Write the generated markdown text to a file.
|
// Write the generated markdown text to a file.
|
||||||
filename := path.Join(dir, bookName+".md")
|
filename := path.Join(dir, bookName+".md")
|
||||||
os.WriteFile(filename, b.Bytes(), 0666)
|
os.WriteFile(filename, b.Bytes(), 0666)
|
||||||
|
clearLine()
|
||||||
printInfo("Saved as: %v", filename)
|
printInfo("Saved as: %v", filename)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user