From eb82e5e447dff67d5bcd1a2d5c9c52990a840e29 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 4 Jun 2017 00:19:35 +0200 Subject: RequestModules(): Pretty print modules Parse the module XML with `ModuleParseXML()`. Take the resulting `[]Module` slice and use it to generate a string of the following format: ID Module 55555 R&D 77777 Sprint 1 222222 Sprint 2 This string is what gets printed to the console, which makes it rather easy to read the modules that are available for the given project and grab the appropriate ID to put into your config file. --- timetask/http.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'timetask') diff --git a/timetask/http.go b/timetask/http.go index 3ff6f4f..575ceae 100644 --- a/timetask/http.go +++ b/timetask/http.go @@ -1,6 +1,8 @@ package timetask import ( + "bytes" + "fmt" "io/ioutil" "net/http" "net/http/cookiejar" @@ -160,5 +162,18 @@ func RequestModules( } response_body := string(body) - return response_body, nil + modules, err := ModuleParseXML(response_body) + if err != nil { + return "", err + } + + var module_buf bytes.Buffer + module_buf.WriteString("ID\tModule\n") + for _, module := range modules { + module_buf.WriteString( + fmt.Sprintf("%d\t%s\n", module.ID, module.Name), + ) + } + + return module_buf.String(), nil } -- cgit v1.2.3