2024-09-30 07:34:40 +02:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
"go-mod.ewintr.nl/planner/plan/storage"
|
|
|
|
)
|
|
|
|
|
|
|
|
var ListCmd = &cli.Command{
|
|
|
|
Name: "list",
|
|
|
|
Usage: "List everything",
|
|
|
|
}
|
|
|
|
|
2024-10-05 14:02:56 +02:00
|
|
|
func NewListCmd(localRepo storage.LocalID, eventRepo storage.Event) *cli.Command {
|
|
|
|
ListCmd.Action = func(cCtx *cli.Context) error {
|
|
|
|
return List(localRepo, eventRepo)
|
|
|
|
}
|
2024-09-30 07:34:40 +02:00
|
|
|
return ListCmd
|
|
|
|
}
|
|
|
|
|
2024-10-05 14:02:56 +02:00
|
|
|
func List(localRepo storage.LocalID, eventRepo storage.Event) error {
|
|
|
|
all, err := eventRepo.FindAll()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, e := range all {
|
|
|
|
fmt.Printf("%s\t%s\t%s\t%s\n", e.ID, e.Title, e.Start.Format(time.DateTime), e.Duration.String())
|
2024-09-30 07:34:40 +02:00
|
|
|
}
|
|
|
|
|
2024-10-05 14:02:56 +02:00
|
|
|
return nil
|
2024-09-30 07:34:40 +02:00
|
|
|
}
|