github.com/grantbow/fit@v0.7.1-0.20220916164603-1f7c88ac81e6/fitapp/Retitle.go (about) 1 package fitapp 2 3 import ( 4 "fmt" 5 bugs "github.com/grantbow/fit/issues" 6 "os" 7 "strings" 8 ) 9 10 //var dops = bugs.Directory(os.PathSeparator) 11 //var sops = string(os.PathSeparator) 12 13 // Relabel is a subcommand to change an issue title. 14 func Relabel(Args argumentList, config bugs.Config) { 15 if len(Args) < 2 { 16 fmt.Printf("Usage: %s relabel <IssueID> New Title\n", os.Args[0]) 17 return 18 } 19 20 b, err := bugs.LoadIssueByHeuristic(Args[0], config) 21 22 if err != nil { 23 fmt.Printf("Could not load issue: %s\n", err.Error()) 24 return 25 } 26 27 currentDir := b.Direr() 28 newDir := bugs.FitDirer(config) + dops + bugs.TitleToDir(strings.Join(Args[1:], " ")) 29 fmt.Printf("Moving %s to %s\n", currentDir, newDir) 30 err = os.Rename(string(currentDir), string(newDir)) 31 if err != nil { 32 fmt.Printf("Error moving directory\n") 33 } 34 }