func AddTag(c *cli.Context, withProject bool) { tagname := c.Args()[1] tag := api.GetTag(tagname) taskId := api.FindTaskId(c.Args().First(), false, false) api.AddTagToTask(tag.Id, taskId) fmt.Println("assigned! : " + tag.Name + " to " + taskId) }
func Comment(c *cli.Context, withProject bool) { taskId := api.FindTaskId(c.Args().First(), false, withProject) task, stories := api.Task(taskId, true) tmpFile := os.TempDir() + "/asana_comment.txt" f, err := os.Create(tmpFile) utils.Check(err) defer f.Close() err = template(f, task, stories) utils.Check(err) cmd := exec.Command(os.Getenv("EDITOR"), tmpFile) cmd.Stdin, cmd.Stdout = os.Stdin, os.Stdout err = cmd.Run() txt, err := ioutil.ReadFile(tmpFile) utils.Check(err) isForClose := getIsForClose(string(txt)) asignee := getAsignee(string(txt)) postComment := trim(string(txt)) if postComment != "" { commented := api.CommentTo(taskId, postComment) fmt.Println("Commented on Task: \"" + task.Name + "\"\n") fmt.Println(commented) if isForClose { result := api.Update(taskId, "completed", "true") fmt.Println("Task closed \"" + task.Name + "\"\n") fmt.Println(result) } if asignee != "" { result := api.Update(taskId, "assignee", api.FindUserId(strings.Replace(asignee, "@", "", -1))) fmt.Println("New asignee \"" + asignee + "\"\n") fmt.Println(result) } } else { fmt.Println("Aborting comment due to empty content.") } }
func Task(c *cli.Context, withProject bool) { t, stories := api.Task(api.FindTaskId(c.Args().First(), true, withProject), c.Bool("verbose")) red := ansi.ColorCode("red") blue := ansi.ColorCode("blue") green := ansi.ColorCode("green") reset := ansi.ColorCode("reset") bold := ansi.ColorCode("white") yellow := ansi.ColorCode("yellow") fmt.Printf("[ %s%s%s ] %s%s%s\n", red, t.Due_on, reset, bold, t.Name, reset) showTags(t.Tags) fmt.Printf("\n%s\n", t.Notes) if stories != nil { fmt.Println("\n----------------------------------------\n") for _, s := range stories { color := "" if strings.HasPrefix(s.String(), "*") { color = blue } match, _ := regexp.MatchString("\\* .* attached", s.String()) if match { color = yellow } if strings.HasPrefix(s.String(), ">") { color = green } fmt.Printf("%s%s%s\n", color, s, reset) } } }
func AssignMe(c *cli.Context, withProject bool) { task := api.Update(api.FindTaskId(c.Args().First(), false, withProject), "assignee", "me") fmt.Println("assigned! : " + task.Name + " to " + task.Assignee.Name) }
func Assign(c *cli.Context, withProject bool) { assignee := c.Args()[1] task := api.Update(api.FindTaskId(c.Args().First(), false, withProject), "assignee", api.FindUserId(assignee)) fmt.Println("assigned! : " + task.Name + " to " + task.Assignee.Name) }
func Done(c *cli.Context, withProject bool) { task := api.Update(api.FindTaskId(c.Args().First(), false, withProject), "completed", "true") fmt.Println("DONE! : " + task.Name) }
func DueOn(c *cli.Context, withProject bool) { taskId := api.FindTaskId(c.Args().First(), true, withProject) task := api.Update(taskId, "due_on", toDate(c.Args()[1])) fmt.Println("set due on [ " + task.Due_on + " ] :" + task.Name) }