From 33727db8bee991115906d3408145d5e0806a2455 Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Sat, 26 Aug 2023 21:47:47 +0200 Subject: feat: Add initial template renderer for markdown --- main.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 9e64dbb..cfc56c4 100644 --- a/main.go +++ b/main.go @@ -6,9 +6,12 @@ import ( "compress/gzip" "errors" "flag" - "fmt" "io" "net/http" + "os" + + "git.sr.ht/~gabrielgio/apkdoc/parser" + "git.sr.ht/~gabrielgio/apkdoc/templates" ) func fechIndex(url string) (io.ReadCloser, error) { @@ -26,6 +29,7 @@ func fechIndex(url string) (io.ReadCloser, error) { func main() { url := flag.String("url", "", "Url to the APKINDEX.tar.gz") + output := flag.String("output", "index.md", "Output path") flag.Parse() tarStream, err := fechIndex(*url) @@ -55,13 +59,13 @@ func main() { s := bufio.NewScanner(tr) - entries := make([]*Entry, 0) + entries := make([]*parser.Entry, 0) lines := make([]string, 0) for s.Scan() { l := s.Text() if l == "" { - entry := Parse(lines) + entry := parser.Parse(lines) entries = append(entries, entry) lines = make([]string, 0) } else { @@ -69,7 +73,10 @@ func main() { } } - for _, e := range entries { - fmt.Printf("%+v\n", e) + file, err := os.Create(*output) + if err != nil { + panic("Error opening output file: " + err.Error()) } + + templates.WriteMarkdownTemplate(file, entries) } -- cgit v1.2.3