diff options
author | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-08-26 21:47:47 +0200 |
---|---|---|
committer | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-08-26 21:47:47 +0200 |
commit | 33727db8bee991115906d3408145d5e0806a2455 (patch) | |
tree | 29676f914f103e6198e48ff5514aace1ca3a97d4 /main.go | |
parent | dd2a1c38a5a9f561d58b58da56d3230fd715fcde (diff) | |
download | apkdoc-33727db8bee991115906d3408145d5e0806a2455.tar.gz apkdoc-33727db8bee991115906d3408145d5e0806a2455.tar.bz2 apkdoc-33727db8bee991115906d3408145d5e0806a2455.zip |
feat: Add initial template renderer for markdown
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -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) } |