@@ -2,7 +2,9 @@ package cli
2
2
3
3
import (
4
4
"fmt"
5
+ "strings"
5
6
7
+ "github.com/fatih/color"
6
8
"golang.org/x/xerrors"
7
9
8
10
"github.com/coder/coder/cli/clibase"
@@ -152,7 +154,27 @@ func (r *RootCmd) listProxies() *clibase.Cmd {
152
154
formatter = cliui .NewOutputFormatter (
153
155
cliui .TableFormat ([]codersdk.WorkspaceProxy {}, []string {"name" , "url" , "status status" }),
154
156
cliui .JSONFormat (),
155
- cliui .TextFormat (),
157
+ cliui .ChangeFormatterData (cliui .TextFormat (), func (data any ) (any , error ) {
158
+ resp , ok := data .([]codersdk.WorkspaceProxy )
159
+ if ! ok {
160
+ return nil , xerrors .Errorf ("unexpected type %T" , data )
161
+ }
162
+ var str strings.Builder
163
+ str .WriteString ("Workspace Proxies:\n " )
164
+ sep := ""
165
+ for i , proxy := range resp {
166
+ str .WriteString (sep )
167
+ str .WriteString (fmt .Sprintf ("%d: %s %s %s" , i , proxy .Name , proxy .URL , proxy .Status .Status ))
168
+ for _ , errMsg := range proxy .Status .Report .Errors {
169
+ str .WriteString (color .RedString ("\n \t Err: %s" , errMsg ))
170
+ }
171
+ for _ , warnMsg := range proxy .Status .Report .Errors {
172
+ str .WriteString (color .YellowString ("\n \t Warn: %s" , warnMsg ))
173
+ }
174
+ sep = "\n "
175
+ }
176
+ return str .String (), nil
177
+ }),
156
178
)
157
179
)
158
180
0 commit comments