From 6f0bbe6345a7d7719ef7f589ffc80eaa3286bae9 Mon Sep 17 00:00:00 2001 From: Brian Downs Date: Mon, 16 May 2016 10:17:21 -0700 Subject: [PATCH 1/2] changed all references of weight to priority in code and comments --- README.md | 6 +++--- command/export.go | 4 ++-- command/parse.go | 44 ++++++++++++++++++++++---------------------- command/show.go | 18 +++++++++--------- command/todo.go | 30 +++++++++++++++--------------- command/weight.go | 15 --------------- 6 files changed, 51 insertions(+), 66 deletions(-) delete mode 100644 command/weight.go diff --git a/README.md b/README.md index a4a57a5..95bc1e1 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,10 @@ Example: TODO(briandowns) this is an example todo format 2016-05-13T18:54 4 ``` -## Weighting +## Priorities ```sh -todo-view weights: +todo-view priorities: 1 Extremely important 2 Somewhat important @@ -29,7 +29,7 @@ todo-view weights: * User * File * Timestamp -* Weight +* Priority ## Usage diff --git a/command/export.go b/command/export.go index a63ef0b..4ead7b5 100644 --- a/command/export.go +++ b/command/export.go @@ -73,7 +73,7 @@ func (e *Export) csv() { } for _, todo := range todos { fmt.Fprintf(os.Stdout, "%s,%s,%s,%v,%d\n", - todo.User(), todo.File(), todo.Message(), todo.Timestamp(), todo.Weight()) + todo.User(), todo.File(), todo.Message(), todo.Timestamp(), todo.Priority()) } } @@ -110,6 +110,6 @@ func (e *Export) jira() { fmt.Fprintln(os.Stdout, "Summary,Assignee,Reporter,Priority") for _, todo := range todos { fmt.Fprintf(os.Stdout, "%s,%s,%s,%d\n", - todo.Message(), todo.User(), todo.User(), todo.Weight()) + todo.Message(), todo.User(), todo.User(), todo.Priority()) } } diff --git a/command/parse.go b/command/parse.go index 10157b7..8e13169 100644 --- a/command/parse.go +++ b/command/parse.go @@ -21,12 +21,12 @@ type Parser interface { byUser() byFile() byDate() - byWeight() + byPriority() } // regex holds the pattern necessary to match the todo in the // files parsed -var regex = regexp.MustCompile(`TODO\((?P[a-z].+)\)(?P.+)(?P\d\d\d\d\D?\d\d\D?\d\d\D?\d\d\D?\d\d\D?(\d\d\.?(\d*))?(\d\d(:\d\d)?)?).(?P\d)`) +var regex = regexp.MustCompile(`TODO\((?P[a-z].+)\)(?P.+)(?P\d\d\d\d\D?\d\d\D?\d\d\D?\d\d\D?\d\d\D?(\d\d\.?(\d*))?(\d\d(:\d\d)?)?).(?P\d)`) // Parse type for command type Parse struct{} @@ -74,15 +74,15 @@ func (p *Parse) Run(args []string) int { } } p.byDate(true) - case "by-weight": + case "by-priority": if len(args) == 2 { switch args[1] { case "-d": - p.byWeight(false) + p.byPriority(false) return 1 } } - p.byWeight(true) + p.byPriority(true) default: fmt.Println("ERROR: invalid option for parse\n") } @@ -97,7 +97,7 @@ Options: by-user [-d decending] Parse todo's by user by-file [-d decending] Parse todo's by file by-date [-d decending] Parse todo's by date - by-weight [-d decending] Parse todo's by weight + by-priority [-d decending] Parse todo's by priority ` } @@ -116,22 +116,22 @@ func printOutput(ot string, t sort.Interface) { case UserTodos: for _, todo := range todoerType { fmt.Fprintf(w, "%s\t%s\t%s\t%v\t%d\n", - todo.User(), todo.File(), todo.Message(), todo.Timestamp(), todo.Weight()) + todo.User(), todo.File(), todo.Message(), todo.Timestamp(), todo.Priority()) } case FileTodos: for _, todo := range todoerType { fmt.Fprintf(w, "%s\t%s\t%s\t%v\t%d\n", - todo.User(), todo.File(), todo.Message(), todo.Timestamp(), todo.Weight()) + todo.User(), todo.File(), todo.Message(), todo.Timestamp(), todo.Priority()) } case TimestampTodos: for _, todo := range todoerType { fmt.Fprintf(w, "%s\t%s\t%s\t%v\t%d\n", - todo.User(), todo.File(), todo.Message(), todo.Timestamp(), todo.Weight()) + todo.User(), todo.File(), todo.Message(), todo.Timestamp(), todo.Priority()) } - case WeightTodos: + case PriorityTodos: for _, todo := range todoerType { fmt.Fprintf(w, "%s\t%s\t%s\t%v\t%d\n", - todo.User(), todo.File(), todo.Message(), todo.Timestamp(), todo.Weight()) + todo.User(), todo.File(), todo.Message(), todo.Timestamp(), todo.Priority()) } } fmt.Fprintf(w, "\n") @@ -194,7 +194,7 @@ func (p *Parse) byDate(decending bool) { switch decending { case true: sort.Sort(timestampTodos) - printOutput("weight", timestampTodos) + printOutput("priority", timestampTodos) return case false: sort.Sort(sort.Reverse(timestampTodos)) @@ -203,24 +203,24 @@ func (p *Parse) byDate(decending bool) { } } -// byWeight outputs the data by weight -func (p *Parse) byWeight(decending bool) { +// byPriority outputs the data by priority +func (p *Parse) byPriority(decending bool) { todos, err := search() if err != nil { log.Fatalln(err) } - weightTodos := make(WeightTodos, len(todos)) + priorityTodos := make(PriorityTodos, len(todos)) for i := 0; i <= len(todos)-1; i++ { - weightTodos[i] = todos[i] + priorityTodos[i] = todos[i] } switch decending { case true: - sort.Sort(weightTodos) - printOutput("weight", weightTodos) + sort.Sort(priorityTodos) + printOutput("priority", priorityTodos) return case false: - sort.Sort(sort.Reverse(weightTodos)) - printOutput("weight", weightTodos) + sort.Sort(sort.Reverse(priorityTodos)) + printOutput("priority", priorityTodos) return } } @@ -276,12 +276,12 @@ func search() ([]Todo, error) { return nil, err } todo.timestamp = ts - case "weight": + case "priority": s, err := strconv.Atoi(match[i]) if err != nil { return nil, err } - todo.weight = s + todo.priority = s } } todos = append(todos, todo) diff --git a/command/show.go b/command/show.go index c70a0e3..ce0c7ed 100644 --- a/command/show.go +++ b/command/show.go @@ -29,8 +29,8 @@ func (s *Show) Run(args []string) int { switch args[0] { case "format": s.showFormat() - case "weights": - s.showWeights() + case "priorities": + s.showPriorities() default: fmt.Println("ERROR: invalid option for show\n") } @@ -43,8 +43,8 @@ func (s *Show) Help() string { return `Usage: todo-view show