Beispiel #1
0
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.")
	}
}
Beispiel #2
0
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)
}
Beispiel #3
0
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)
}
Beispiel #4
0
func Done(c *cli.Context, withProject bool) {
	task := api.Update(api.FindTaskId(c.Args().First(), false, withProject), "completed", "true")
	fmt.Println("DONE! : " + task.Name)
}
Beispiel #5
0
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)
}