From d833ffe6cd5efd97b00f907ed426a88275a8c8db Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 3 Jun 2017 23:08:08 +0200 Subject: Add an option to list "Modules" (sprints & their IDs) Sprints will change with time while the other IDs of a project will stay the same. Thus sprints, which live in the `Module` field, must be updated regularly. In order to facilitate that updating, instead of requiring users to get those IDs directly from the TimeTask website every time, have them use this command to get the names of sprints and their IDs. They can then update the ID manually in their config file. This code makes a request to the endpoint that returns module IDs for the site (the site queries this via AJAX to update its interface). The result of the request is some XML containing the modules and their IDs. For now I'm just printing this out. We'll want to parse the XML and display it in a nicer way. --- main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'main.go') diff --git a/main.go b/main.go index 861dc8b..1521821 100644 --- a/main.go +++ b/main.go @@ -42,6 +42,7 @@ func main() { ) write_config := kingpin.Flag("write-config", write_config_description). Bool() + list_modules := kingpin.Flag("list-modules", "List sprints with IDs").Bool() kingpin.Version(VERSION) kingpin.Parse() @@ -108,6 +109,15 @@ func main() { os.Exit(1) } + // List modules + if *list_modules { + modules, err := timetask.RequestModules(*client, time_entry) + kingpin.FatalIfError(err, "could not retrieve sprints") + fmt.Println(modules) + + os.Exit(0) + } + resp, err = timetask.SubmitTimeEntry(*client, time_entry) kingpin.FatalIfError(err, "time entry submission request failed") -- cgit v1.2.3