File size: 481 Bytes
6a7089a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package actions

import (
	"fmt"
	"github.com/pinchtab/pinchtab/internal/cli/apiclient"
	"github.com/spf13/cobra"
	"net/http"
	"strings"
)

func Evaluate(client *http.Client, base, token string, args []string, cmd *cobra.Command) {
	body := map[string]any{"expression": strings.Join(args, " ")}
	tabID, _ := cmd.Flags().GetString("tab")
	path := "/evaluate"
	if tabID != "" {
		path = fmt.Sprintf("/tabs/%s/evaluate", tabID)
	}
	apiclient.DoPost(client, base, token, path, body)
}