예제 #1
0
파일: comment.go 프로젝트: dbalseiro/asana
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.")
	}
}
예제 #2
0
파일: assign.go 프로젝트: dbalseiro/asana
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)
}