-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync.go
39 lines (34 loc) · 971 Bytes
/
sync.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"github.com/mateothegreat/go-multilog/multilog"
"github.com/polyrepopro/api/workspaces"
"github.com/spf13/cobra"
)
func init() {
syncCommand.Flags().StringP("workspace", "w", "", "the name of the workspace to sync")
root.AddCommand(syncCommand)
}
var syncCommand = &cobra.Command{
Use: "sync",
Short: "Sync a workspace by syncing all repositories",
Long: "Sync a workspace by syncing all repositories",
Run: func(cmd *cobra.Command, args []string) {
workspaceName, err := cmd.Flags().GetString("workspace")
if err != nil {
multilog.Fatal("workspace.sync", "sync failed", map[string]interface{}{
"error": err,
})
}
msgs, err := workspaces.Sync(workspaces.SyncArgs{
Name: workspaceName,
})
if err != nil {
multilog.Fatal("workspace.sync", "sync failed", map[string]interface{}{
"error": err,
})
}
multilog.Info("workspace.sync", "synced", map[string]interface{}{
"messages": msgs,
})
},
}