func Comment(c *cli.Context) { taskId := api.FindTaskId(c.Args().First(), false) 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) postComment := trim(string(txt)) if postComment != "" { commented := api.CommentTo(taskId, postComment) fmt.Println("Commented on Task: \"" + task.Name + "\"\n") fmt.Println(commented) } else { fmt.Println("Aborting comment due to empty content.") } }
func Browse(c *cli.Context) { taskId := api.FindTaskId(c.Args().First(), true) url := "https://app.asana.com/0/" + strconv.Itoa(config.Load().Workspace) + "/" + taskId launcher, err := utils.BrowserLauncher() utils.Check(err) cmd := exec.Command(launcher, url) err = cmd.Start() utils.Check(err) }
func Task(c *cli.Context) { t, stories := api.Task(api.FindTaskId(c.Args().First(), true), c.Bool("verbose")) fmt.Printf("[ %s ] %s\n", t.Due_on, t.Name) showTags(t.Tags) fmt.Printf("\n%s\n", t.Notes) if stories != nil { fmt.Println("\n----------------------------------------\n") for _, s := range stories { fmt.Printf("%s\n", s) } } }
func DueOn(c *cli.Context) { taskId := api.FindTaskId(c.Args().First(), true) task := api.Update(taskId, "due_on", toDate(c.Args()[1])) fmt.Println("set due on [ " + task.Due_on + " ] :" + task.Name) }
func Done(c *cli.Context) { task := api.Update(api.FindTaskId(c.Args().First(), false), "completed", "true") fmt.Println("DONE! : " + task.Name) }