diff options
Diffstat (limited to 'packages/sdk/go/command.go')
| -rw-r--r-- | packages/sdk/go/command.go | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/packages/sdk/go/command.go b/packages/sdk/go/command.go index 9ca70c3ac..2638fc607 100644 --- a/packages/sdk/go/command.go +++ b/packages/sdk/go/command.go @@ -5,8 +5,11 @@ package opencode import ( "context" "net/http" + "net/url" "github.com/sst/opencode-sdk-go/internal/apijson" + "github.com/sst/opencode-sdk-go/internal/apiquery" + "github.com/sst/opencode-sdk-go/internal/param" "github.com/sst/opencode-sdk-go/internal/requestconfig" "github.com/sst/opencode-sdk-go/option" ) @@ -31,10 +34,10 @@ func NewCommandService(opts ...option.RequestOption) (r *CommandService) { } // List all commands -func (r *CommandService) List(ctx context.Context, opts ...option.RequestOption) (res *[]Command, err error) { +func (r *CommandService) List(ctx context.Context, query CommandListParams, opts ...option.RequestOption) (res *[]Command, err error) { opts = append(r.Options[:], opts...) path := "command" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return } @@ -65,3 +68,15 @@ func (r *Command) UnmarshalJSON(data []byte) (err error) { func (r commandJSON) RawJSON() string { return r.raw } + +type CommandListParams struct { + Directory param.Field[string] `query:"directory"` +} + +// URLQuery serializes [CommandListParams]'s query parameters as `url.Values`. +func (r CommandListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} |
