prolific2jira/main.go

70 lines
1.3 KiB
Go
Raw Normal View History

2015-10-13 00:01:07 -04:00
package main
import (
"bufio"
"encoding/csv"
"flag"
"fmt"
"io"
"log"
"os"
)
var user = flag.String("user", "user", "jira username")
var pass = flag.String("pass", "NotAPassword1", "jira password")
var prj = flag.String("prj", "PROJ", "jira project to add stories to")
var svr = flag.String("svr", "https://jira.example.com", "jira server url")
2015-10-13 00:01:07 -04:00
func main() {
if len(os.Args) != 9 {
flag.PrintDefaults()
return
}
2015-10-30 00:02:04 -04:00
flag.Parse()
// fmt.Printf("%v", os.Args)
// fmt.Printf(*svr)
bufrdr := bufio.NewReader(os.Stdin)
bufrdr.ReadLine()
// processIssue(csvrdr, printJSON)
processIssue(bufrdr, submitIssue, *user, *pass, *svr, *prj)
}
2015-10-13 00:01:07 -04:00
type procFunc func(i []string, user string, pass string, srv string, prj string) error
func processIssue(r io.Reader, process procFunc, user string, pass string, svr string, prj string) error {
csvrdr := csv.NewReader(r)
for {
record, err := csvrdr.Read()
if err == io.EOF {
break
}
if err != nil {
log.Fatal(err)
}
err = process(record, user, pass, svr, prj)
if err != nil {
log.Fatal(err)
}
}
return nil
}
func printCSV(issue []string, user string, pass string, svr string, prj string) error {
fmt.Println(issue)
return nil
}
func printJSON(issue []string, user string, pass string, svr string, prj string) error {
i := newIssue(issue, prj)
2015-10-13 02:16:05 -04:00
fmt.Println(string(toJSON(i)))
return nil
2015-10-13 00:01:07 -04:00
}