Skip to content

Commit 62f676b

Browse files
committed
Fix formats
1 parent 4d7daed commit 62f676b

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

cli/cliui/output.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,30 @@ func (textFormat) AttachOptions(_ *clibase.OptionSet) {}
192192
func (textFormat) Format(_ context.Context, data any) (string, error) {
193193
return fmt.Sprintf("%s", data), nil
194194
}
195+
196+
type DataChangeFormat struct {
197+
format OutputFormat
198+
change func(data any) (any, error)
199+
}
200+
201+
// ChangeFormatterData allows manipulating the data passed to an output
202+
// format.
203+
func ChangeFormatterData(format OutputFormat, change func(data any) (any, error)) *DataChangeFormat {
204+
return &DataChangeFormat{format: format, change: change}
205+
}
206+
207+
func (d *DataChangeFormat) ID() string {
208+
return d.format.ID()
209+
}
210+
211+
func (d *DataChangeFormat) AttachOptions(opts *clibase.OptionSet) {
212+
d.format.AttachOptions(opts)
213+
}
214+
215+
func (d *DataChangeFormat) Format(ctx context.Context, data any) (string, error) {
216+
newData, err := d.change(data)
217+
if err != nil {
218+
return "", err
219+
}
220+
return d.format.Format(ctx, newData)
221+
}

codersdk/workspaceproxy.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ type CreateWorkspaceProxyRequest struct {
3333
}
3434

3535
type CreateWorkspaceProxyResponse struct {
36-
Proxy WorkspaceProxy `json:"proxy" table:"proxy,recursive,default_sort"`
37-
ProxyToken string `json:"proxy_token"`
36+
Proxy WorkspaceProxy `json:"proxy" table:"proxy,recursive"`
37+
// The recursive table sort is not working very well.
38+
ProxyToken string `json:"proxy_token" table:"proxy token,default_sort"`
3839
}
3940

4041
func (c *Client) CreateWorkspaceProxy(ctx context.Context, req CreateWorkspaceProxyRequest) (CreateWorkspaceProxyResponse, error) {

0 commit comments

Comments
 (0)