forked from anomalyco/opencode-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.go
More file actions
41 lines (35 loc) · 913 Bytes
/
command.go
File metadata and controls
41 lines (35 loc) · 913 Bytes
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
40
41
package opencode
import (
"context"
"github.com/dominicnunez/opencode-sdk-go/internal/queryparams"
"net/http"
"net/url"
)
type CommandService struct {
client *Client
}
func (s *CommandService) List(ctx context.Context, params *CommandListParams) ([]Command, error) {
if params == nil {
params = &CommandListParams{}
}
var result []Command
err := s.client.do(ctx, http.MethodGet, "command", params, &result)
if err != nil {
return nil, err
}
return result, nil
}
type Command struct {
Name string `json:"name"`
Template string `json:"template"`
Agent string `json:"agent"`
Description string `json:"description"`
Model string `json:"model"`
Subtask bool `json:"subtask"`
}
type CommandListParams struct {
Directory *string `json:"-" query:"directory,omitempty"`
}
func (r CommandListParams) URLQuery() (url.Values, error) {
return queryparams.Marshal(r)
}