planner/plan/command/sync.go

43 lines
857 B
Go
Raw Normal View History

2024-10-07 11:11:18 +02:00
package command
import (
"github.com/urfave/cli/v2"
"go-mod.ewintr.nl/planner/plan/storage"
2024-10-07 11:32:53 +02:00
"go-mod.ewintr.nl/planner/sync/client"
2024-10-07 11:11:18 +02:00
)
var SyncCmd = &cli.Command{
Name: "sync",
2024-10-09 07:26:39 +02:00
Usage: "Synchronize with server",
2024-10-07 11:11:18 +02:00
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "full",
Aliases: []string{"f"},
Usage: "Force full sync",
},
},
}
2024-10-07 11:32:53 +02:00
func NewSyncCmd(client *client.Client, localRepo storage.LocalID, eventRepo storage.Event) *cli.Command {
2024-10-07 11:11:18 +02:00
SyncCmd.Action = func(cCtx *cli.Context) error {
2024-10-07 11:32:53 +02:00
return Sync(client, localRepo, eventRepo, cCtx.Bool("full"))
2024-10-07 11:11:18 +02:00
}
return SyncCmd
}
2024-10-07 11:32:53 +02:00
func Sync(client *client.Client, localRepo storage.LocalID, eventRepo storage.Event, full bool) error {
2024-10-09 07:26:39 +02:00
// find local new and updated
// send new and updated
//
2024-10-07 11:32:53 +02:00
// get new/updated items
// delete deleted
// update existing
// localid and add new
2024-10-07 11:11:18 +02:00
return nil
}