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",
|
|
|
|
Usage: "Synchonize with server",
|
|
|
|
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 {
|
|
|
|
// get new/updated items
|
|
|
|
|
|
|
|
// delete deleted
|
|
|
|
|
|
|
|
// update existing
|
|
|
|
|
|
|
|
// localid and add new
|
|
|
|
|
|
|
|
// find local new and updated
|
|
|
|
|
|
|
|
// send new and updated
|
2024-10-07 11:11:18 +02:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|