aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-08-26 21:47:47 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-08-26 21:47:47 +0200
commit33727db8bee991115906d3408145d5e0806a2455 (patch)
tree29676f914f103e6198e48ff5514aace1ca3a97d4 /main.go
parentdd2a1c38a5a9f561d58b58da56d3230fd715fcde (diff)
downloadapkdoc-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.go17
1 files changed, 12 insertions, 5 deletions
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)
}