display uuid
This commit is contained in:
parent
1a8f72e364
commit
addf95a2e7
|
@ -2,7 +2,6 @@ package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"git.ewintr.nl/gte/internal/configuration"
|
"git.ewintr.nl/gte/internal/configuration"
|
||||||
)
|
)
|
||||||
|
@ -34,7 +33,3 @@ func Parse(args []string, conf *configuration.Configuration) (Command, error) {
|
||||||
return NewEmpty()
|
return NewEmpty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func FormatError(err error) string {
|
|
||||||
return fmt.Sprintf("could not perform command.\n\nerror: %s\n", err.Error())
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.ewintr.nl/gte/cmd/cli/format"
|
||||||
"git.ewintr.nl/gte/internal/configuration"
|
"git.ewintr.nl/gte/internal/configuration"
|
||||||
"git.ewintr.nl/gte/internal/storage"
|
"git.ewintr.nl/gte/internal/storage"
|
||||||
"git.ewintr.nl/gte/internal/task"
|
"git.ewintr.nl/gte/internal/task"
|
||||||
|
@ -28,7 +29,7 @@ func NewNew(conf *configuration.Configuration, cmdArgs []string) (*New, error) {
|
||||||
|
|
||||||
func (n *New) Do() string {
|
func (n *New) Do() string {
|
||||||
if err := n.disp.Dispatch(&task.Task{Action: n.action}); err != nil {
|
if err := n.disp.Dispatch(&task.Task{Action: n.action}); err != nil {
|
||||||
return FormatError(err)
|
return format.FormatError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return "message sent\n"
|
return "message sent\n"
|
||||||
|
|
|
@ -3,6 +3,7 @@ package command
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"git.ewintr.nl/gte/cmd/cli/format"
|
||||||
"git.ewintr.nl/gte/internal/configuration"
|
"git.ewintr.nl/gte/internal/configuration"
|
||||||
"git.ewintr.nl/gte/internal/process"
|
"git.ewintr.nl/gte/internal/process"
|
||||||
"git.ewintr.nl/gte/internal/storage"
|
"git.ewintr.nl/gte/internal/storage"
|
||||||
|
@ -30,7 +31,7 @@ func NewSync(conf *configuration.Configuration) (*Sync, error) {
|
||||||
func (s *Sync) Do() string {
|
func (s *Sync) Do() string {
|
||||||
result, err := s.syncer.Process()
|
result, err := s.syncer.Process()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return FormatError(err)
|
return format.FormatError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("synced %d tasks\n", result.Count)
|
return fmt.Sprintf("synced %d tasks\n", result.Count)
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"git.ewintr.nl/gte/cmd/cli/format"
|
||||||
|
|
||||||
"git.ewintr.nl/gte/internal/configuration"
|
"git.ewintr.nl/gte/internal/configuration"
|
||||||
"git.ewintr.nl/gte/internal/process"
|
"git.ewintr.nl/gte/internal/process"
|
||||||
"git.ewintr.nl/gte/internal/storage"
|
"git.ewintr.nl/gte/internal/storage"
|
||||||
|
@ -33,16 +32,11 @@ func NewToday(conf *configuration.Configuration) (*Today, error) {
|
||||||
func (t *Today) Do() string {
|
func (t *Today) Do() string {
|
||||||
res, err := t.todayer.Process()
|
res, err := t.todayer.Process()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return FormatError(err)
|
return format.FormatError(err)
|
||||||
}
|
}
|
||||||
if len(res.Tasks) == 0 {
|
if len(res.Tasks) == 0 {
|
||||||
return "nothing left\n"
|
return "nothing left\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
var msg string
|
return format.FormatTaskTable(res.Tasks)
|
||||||
for _, t := range res.Tasks {
|
|
||||||
msg += fmt.Sprintf("%s - %s\n", t.Project, t.Action)
|
|
||||||
}
|
|
||||||
|
|
||||||
return msg
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"git.ewintr.nl/gte/cmd/cli/format"
|
||||||
|
|
||||||
"git.ewintr.nl/gte/internal/configuration"
|
"git.ewintr.nl/gte/internal/configuration"
|
||||||
"git.ewintr.nl/gte/internal/process"
|
"git.ewintr.nl/gte/internal/process"
|
||||||
"git.ewintr.nl/gte/internal/storage"
|
"git.ewintr.nl/gte/internal/storage"
|
||||||
|
@ -33,17 +32,12 @@ func NewTomorrow(conf *configuration.Configuration) (*Tomorrow, error) {
|
||||||
func (t *Tomorrow) Do() string {
|
func (t *Tomorrow) Do() string {
|
||||||
res, err := t.tomorrower.Process()
|
res, err := t.tomorrower.Process()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return FormatError(err)
|
return format.FormatError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(res.Tasks) == 0 {
|
if len(res.Tasks) == 0 {
|
||||||
return "nothing to do tomorrow\n"
|
return "nothing to do tomorrow\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
var msg string
|
return format.FormatTaskTable(res.Tasks)
|
||||||
for _, t := range res.Tasks {
|
|
||||||
msg += fmt.Sprintf("%s - %s", t.Project, t.Action)
|
|
||||||
}
|
|
||||||
|
|
||||||
return msg
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package format
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"git.ewintr.nl/gte/internal/task"
|
||||||
|
)
|
||||||
|
|
||||||
|
func FormatError(err error) string {
|
||||||
|
return fmt.Sprintf("could not perform command.\n\nerror: %s\n", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func FormatTaskTable(tasks []*task.Task) string {
|
||||||
|
var output string
|
||||||
|
for _, t := range tasks {
|
||||||
|
output += fmt.Sprintf("%s\t%s\t%s\n", t.Id, t.Due.String(), t.Action)
|
||||||
|
}
|
||||||
|
|
||||||
|
return output
|
||||||
|
}
|
Loading…
Reference in New Issue