add signaldctl account request-sync

This commit is contained in:
finn 2022-04-25 17:05:37 -07:00
parent 204657b38b
commit e50f392288
2 changed files with 40 additions and 2 deletions

View file

@ -0,0 +1,36 @@
package requestsync
import (
"log"
"github.com/spf13/cobra"
"gitlab.com/signald/signald-go/cmd/signaldctl/common"
"gitlab.com/signald/signald-go/cmd/signaldctl/config"
v1 "gitlab.com/signald/signald-go/signald/client-protocol/v1"
)
var (
account string
RequestSyncCmd = &cobra.Command{
Use: "request-sync",
Short: "Ask other devices on the account to send sync data. Must subscribe for result",
PreRun: func(cmd *cobra.Command, args []string) {
if account == "" {
account = config.Config.DefaultAccount
}
},
Run: func(_ *cobra.Command, _ []string) {
go common.Signald.Listen(nil)
req := &v1.RequestSyncRequest{Account: account}
err := req.Submit(common.Signald)
if err != nil {
panic(err)
}
log.Println("sync requested. Must be subscribed to receive response")
},
}
)
func init() {
RequestSyncCmd.Flags().StringVarP(&account, "account", "a", "", "the signald account to use")
}

View file

@ -23,6 +23,7 @@ import (
"gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/list" "gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/list"
"gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/register" "gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/register"
"gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/remoteconfig" "gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/remoteconfig"
"gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/requestsync"
"gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/setprofile" "gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/setprofile"
"gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/verify" "gitlab.com/signald/signald-go/cmd/signaldctl/cmd/account/verify"
) )
@ -37,7 +38,8 @@ func init() {
AccountCmd.AddCommand(link.LinkAccountCmd) AccountCmd.AddCommand(link.LinkAccountCmd)
AccountCmd.AddCommand(list.ListAccountCmd) AccountCmd.AddCommand(list.ListAccountCmd)
AccountCmd.AddCommand(register.RegisterAccountCmd) AccountCmd.AddCommand(register.RegisterAccountCmd)
AccountCmd.AddCommand(verify.VerifyAccountCmd)
AccountCmd.AddCommand(setprofile.SetProfileCmd)
AccountCmd.AddCommand(remoteconfig.RemoteConfigCmd) AccountCmd.AddCommand(remoteconfig.RemoteConfigCmd)
AccountCmd.AddCommand(requestsync.RequestSyncCmd)
AccountCmd.AddCommand(setprofile.SetProfileCmd)
AccountCmd.AddCommand(verify.VerifyAccountCmd)
} }