github.com/grantbow/bug@v0.3.1/bugapp/Relabel.go (about)

     1  package bugapp
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/driusan/bug/bugs"
     6  	"os"
     7  	"strings"
     8  )
     9  
    10  func Relabel(Args ArgumentList) {
    11  	if len(Args) < 2 {
    12  		fmt.Printf("Usage: %s relabel BugID New Title\n", os.Args[0])
    13  		return
    14  	}
    15  
    16  	b, err := bugs.LoadBugByHeuristic(Args[0])
    17  
    18  	if err != nil {
    19  		fmt.Printf("Could not load bug: %s\n", err.Error())
    20  		return
    21  	}
    22  
    23  	currentDir := b.GetDirectory()
    24  	newDir := bugs.GetIssuesDir() + bugs.TitleToDir(strings.Join(Args[1:], " "))
    25  	fmt.Printf("Moving %s to %s\n", currentDir, newDir)
    26  	err = os.Rename(string(currentDir), string(newDir))
    27  	if err != nil {
    28  		fmt.Printf("Error moving directory\n")
    29  	}
    30  }