package main
import (
"bufio"
"d1pkgweb/deb822"
"fmt"
"os"
)
var templ = `
{{.Name}}-{{.Version}}
{{.Name}} {{.Version}}
{{.Description}}
{{.LongDescription}}
Depends:
{{range .Depends}}- {{ . }}
{{end}}
Recommends:
{{range .Recommends}}- {{ . }}
{{end}}
Maintainer: {{.Maintainer}}
`
func main() {
args := os.Args
if len(args) < 2 {
fmt.Printf("Usage: %s \n", args[0])
return
}
fnames := args[1:]
for _, fname := range fnames {
f, err := os.Open(fname)
if err != nil {
defer f.Close()
}
if err != nil {
fmt.Printf("Error opening file %s\n", fname)
} else {
r := bufio.NewScanner(f)
if r != nil {
for s, err := deb822.ScanStanza(r); s["Package"] != ""; s, err = deb822.ScanStanza(r) {
if err == nil {
deb822.Stanza2HtmlPage(s, templ, ".")
} else {
fmt.Printf("error: %s\n", err)
}
//WriteFiles(s, num, "./files/")
}
}
}
}
}