Exemplo n.º 1
0
Arquivo: Tag.go Projeto: Komosa/bug
func Tag(Args ArgumentList) {
	if len(Args) < 2 {
		fmt.Printf("Usage: %s tag [--rm] BugID tagname [more tagnames]\n", os.Args[0])
		fmt.Printf("\nBoth issue number and tagname to set are required.\n")
		fmt.Printf("\nCurrently used tags in entire tree: %s\n", strings.Join(getAllTags(), ", "))
		return
	}
	var removeTags bool = false
	if Args[0] == "--rm" {
		removeTags = true
		Args = Args[1:]
	}

	b, err := bugs.LoadBugByHeuristic(Args[0])

	if err != nil {
		fmt.Printf("Could not load bug: %s\n", err.Error())
		return
	}
	for _, tag := range Args[1:] {
		if removeTags {
			b.RemoveTag(bugs.Tag(tag))
		} else {
			b.TagBug(bugs.Tag(tag))
		}
	}

}
Exemplo n.º 2
0
Arquivo: List.go Projeto: Komosa/bug
func listTags(files []os.FileInfo, args ArgumentList) {
	b := bugs.Bug{}
	for idx, _ := range files {
		b.LoadBug(bugs.Directory(bugs.GetIssuesDir() + bugs.Directory(files[idx].Name())))

		for _, tag := range args {
			if b.HasTag(bugs.Tag(tag)) {
				fmt.Printf("%s: %s\n", getBugName(b, idx), b.Title("tags"))
			}
		}
	}
}
Exemplo n.º 3
0
func (a BugApplication) Tag(Args []string) {
	if len(Args) < 2 {
		fmt.Printf("Usage: %s tag issuenum tagname [more tagnames]\n", os.Args[0])
		fmt.Printf("\nBoth issue number and tagname to set are required.\n")
		fmt.Printf("\nCurrently used tags in entire tree: %s\n", strings.Join(getAllTags(), ", "))
		return
	}

	b, err := bugs.LoadBugByStringIndex(Args[0])

	if err != nil {
		fmt.Printf("Could not load bug: %s\n", err.Error())
		return
	}
	for _, tag := range Args[1:] {
		b.TagBug(bugs.Tag(tag))
	}

}
Exemplo n.º 4
0
Arquivo: Create.go Projeto: Komosa/bug
func Create(Args ArgumentList) {
	if len(Args) < 1 || (len(Args) < 2 && Args[0] == "-n") {
		fmt.Fprintf(os.Stderr, "Usage: %s create [-n] Bug Description\n", os.Args[0])
		fmt.Fprintf(os.Stderr, "\nNo Bug Description provided.\n")
		return
	}
	var noDesc bool = false

	if Args.HasArgument("-n") {
		noDesc = true
		Args = Args[1:]
	}

	Args, argVals := Args.GetAndRemoveArguments([]string{"--tag", "--status", "--priority", "--milestone", "--identifier"})
	tag := argVals[0]
	status := argVals[1]
	priority := argVals[2]
	milestone := argVals[3]
	identifier := argVals[4]

	if Args.HasArgument("--generate-id") {
		for i, token := range Args {
			if token == "--generate-id" {
				if i+1 < len(Args) {
					Args = append(Args[:i], Args[i+1:]...)
					break
				} else {
					Args = Args[:i]
					break
				}
			}
		}
		identifier = generateID(strings.Join(Args, " "))
	}

	var bug bugs.Bug
	bug = bugs.Bug{
		Dir: bugs.GetIssuesDir() + bugs.TitleToDir(strings.Join(Args, " ")),
	}

	dir := bug.GetDirectory()

	var mode os.FileMode
	mode = 0775
	os.Mkdir(string(dir), mode)

	if noDesc {
		txt := []byte("")
		ioutil.WriteFile(string(dir)+"/Description", txt, 0644)
	} else {
		cmd := exec.Command(getEditor(), string(dir)+"/Description")

		cmd.Stdin = os.Stdin
		cmd.Stdout = os.Stdout
		cmd.Stderr = os.Stderr
		err := cmd.Run()

		if err != nil {
			log.Fatal(err)
		}
	}

	if tag != "" {
		bug.TagBug(bugs.Tag(tag))
	}
	if status != "" {
		bug.SetStatus(status)
	}
	if priority != "" {
		bug.SetPriority(priority)
	}
	if milestone != "" {
		bug.SetMilestone(milestone)
	}
	if identifier != "" {
		bug.SetIdentifier(identifier)
	}
	fmt.Printf("Created issue: %s\n", bug.Title(""))
}