oef/scripts/export_responses/main.go

37 lines
681 B
Go
Raw Permalink Normal View History

2020-12-28 12:41:37 +01:00
package main
import (
"flag"
"os"
"git.andreafazzi.eu/andrea/oef/client"
"git.andreafazzi.eu/andrea/oef/orm"
"github.com/gocarina/gocsv"
)
func main() {
username := flag.String("username", "admin", "Username")
password := flag.String("password", "admin", "Password")
output := flag.String("output", "responses.csv", "Output filename")
flag.Parse()
client, err := client.Dial(flag.Arg(0), *username, *password)
if err != nil {
panic(err)
}
responses := make([]*orm.Response, 0)
err = client.ReadAll(&responses)
if err != nil {
panic(err)
}
f, err := os.Create(*output)
if err != nil {
panic(err)
}
defer f.Close()
gocsv.MarshalFile(responses, f)
}