Skip to content

Commit c2f7660

Browse files
committed
remove old style wshrpc calls from wshcmd files...
1 parent b1d3885 commit c2f7660

File tree

9 files changed

+15
-13
lines changed

9 files changed

+15
-13
lines changed

cmd/wsh/cmd/wshcmd-connserver.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,10 @@ func serverRunRouter(jwtToken string) error {
191191

192192
func checkForUpdate() error {
193193
remoteInfo := wshutil.GetInfo()
194-
needsRestartRaw, err := RpcClient.SendRpcRequest(wshrpc.Command_ConnUpdateWsh, remoteInfo, &wshrpc.RpcOpts{Timeout: 60000})
194+
needsRestart, err := wshclient.ConnUpdateWshCommand(RpcClient, remoteInfo, &wshrpc.RpcOpts{Timeout: 60000})
195195
if err != nil {
196196
return fmt.Errorf("could not update: %w", err)
197197
}
198-
needsRestart, ok := needsRestartRaw.(bool)
199-
if !ok {
200-
return fmt.Errorf("wrong return type from update")
201-
}
202198
if needsRestart {
203199
// run the restart command here
204200
// how to get the correct path?

cmd/wsh/cmd/wshcmd-deleteblock.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/spf13/cobra"
1010
"github.com/wavetermdev/waveterm/pkg/wshrpc"
11+
"github.com/wavetermdev/waveterm/pkg/wshrpc/wshclient"
1112
)
1213

1314
var deleteBlockCmd = &cobra.Command{
@@ -35,7 +36,7 @@ func deleteBlockRun(cmd *cobra.Command, args []string) (rtnErr error) {
3536
deleteBlockData := &wshrpc.CommandDeleteBlockData{
3637
BlockId: fullORef.OID,
3738
}
38-
_, err = RpcClient.SendRpcRequest(wshrpc.Command_DeleteBlock, deleteBlockData, &wshrpc.RpcOpts{Timeout: 2000})
39+
err = wshclient.DeleteBlockCommand(RpcClient, *deleteBlockData, &wshrpc.RpcOpts{Timeout: 2000})
3940
if err != nil {
4041
return fmt.Errorf("delete block failed: %v", err)
4142
}

cmd/wsh/cmd/wshcmd-editconfig.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/spf13/cobra"
1010
"github.com/wavetermdev/waveterm/pkg/waveobj"
1111
"github.com/wavetermdev/waveterm/pkg/wshrpc"
12+
"github.com/wavetermdev/waveterm/pkg/wshrpc/wshclient"
1213
)
1314

1415
var editConfigMagnified bool
@@ -48,7 +49,7 @@ func editConfigRun(cmd *cobra.Command, args []string) (rtnErr error) {
4849
Focused: true,
4950
}
5051

51-
_, err := RpcClient.SendRpcRequest(wshrpc.Command_CreateBlock, wshCmd, &wshrpc.RpcOpts{Timeout: 2000})
52+
_, err := wshclient.CreateBlockCommand(RpcClient, *wshCmd, &wshrpc.RpcOpts{Timeout: 2000})
5253
if err != nil {
5354
return fmt.Errorf("opening config file: %w", err)
5455
}

cmd/wsh/cmd/wshcmd-notify.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/spf13/cobra"
1010
"github.com/wavetermdev/waveterm/pkg/wshrpc"
11+
"github.com/wavetermdev/waveterm/pkg/wshrpc/wshclient"
1112
"github.com/wavetermdev/waveterm/pkg/wshutil"
1213
)
1314

@@ -38,7 +39,7 @@ func notifyRun(cmd *cobra.Command, args []string) (rtnErr error) {
3839
Body: message,
3940
Silent: notifySilent,
4041
}
41-
_, err := RpcClient.SendRpcRequest(wshrpc.Command_Notify, notificationOptions, &wshrpc.RpcOpts{Timeout: 2000, Route: wshutil.ElectronRoute})
42+
err := wshclient.NotifyCommand(RpcClient, *notificationOptions, &wshrpc.RpcOpts{Timeout: 2000, Route: wshutil.ElectronRoute})
4243
if err != nil {
4344
return fmt.Errorf("sending notification: %w", err)
4445
}

cmd/wsh/cmd/wshcmd-secret.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func secretUiRun(cmd *cobra.Command, args []string) (rtnErr error) {
187187
Focused: true,
188188
}
189189

190-
_, err := RpcClient.SendRpcRequest(wshrpc.Command_CreateBlock, wshCmd, &wshrpc.RpcOpts{Timeout: 2000})
190+
_, err := wshclient.CreateBlockCommand(RpcClient, *wshCmd, &wshrpc.RpcOpts{Timeout: 2000})
191191
if err != nil {
192192
return fmt.Errorf("opening secrets UI: %w", err)
193193
}

cmd/wsh/cmd/wshcmd-setmeta.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/spf13/cobra"
1515
"github.com/wavetermdev/waveterm/pkg/wshrpc"
16+
"github.com/wavetermdev/waveterm/pkg/wshrpc/wshclient"
1617
)
1718

1819
var setMetaCmd = &cobra.Command{
@@ -192,7 +193,7 @@ func setMetaRun(cmd *cobra.Command, args []string) (rtnErr error) {
192193
ORef: *fullORef,
193194
Meta: fullMeta,
194195
}
195-
_, err = RpcClient.SendRpcRequest(wshrpc.Command_SetMeta, setMetaWshCmd, &wshrpc.RpcOpts{Timeout: 2000})
196+
err = wshclient.SetMetaCommand(RpcClient, *setMetaWshCmd, &wshrpc.RpcOpts{Timeout: 2000})
196197
if err != nil {
197198
return fmt.Errorf("setting metadata: %v", err)
198199
}

cmd/wsh/cmd/wshcmd-view.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/spf13/cobra"
1414
"github.com/wavetermdev/waveterm/pkg/waveobj"
1515
"github.com/wavetermdev/waveterm/pkg/wshrpc"
16+
"github.com/wavetermdev/waveterm/pkg/wshrpc/wshclient"
1617
)
1718

1819
var viewMagnified bool
@@ -99,7 +100,7 @@ func viewRun(cmd *cobra.Command, args []string) (rtnErr error) {
99100
wshCmd.BlockDef.Meta[waveobj.MetaKey_Connection] = conn
100101
}
101102
}
102-
_, err := RpcClient.SendRpcRequest(wshrpc.Command_CreateBlock, wshCmd, &wshrpc.RpcOpts{Timeout: 2000})
103+
_, err := wshclient.CreateBlockCommand(RpcClient, *wshCmd, &wshrpc.RpcOpts{Timeout: 2000})
103104
if err != nil {
104105
return fmt.Errorf("running view command: %w", err)
105106
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/wshrpc/wshrpctypes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const (
5858
Command_RouteAnnounce = "routeannounce" // special (for routing)
5959
Command_RouteUnannounce = "routeunannounce" // special (for routing)
6060
Command_Message = "message"
61+
6162
Command_GetMeta = "getmeta"
6263
Command_SetMeta = "setmeta"
6364
Command_SetView = "setview"

0 commit comments

Comments
 (0)