@@ -67,13 +67,9 @@ func (c BrowserPoolsCmd) List(ctx context.Context, in BrowserPoolsListInput) err
6767 }
6868
6969 for _ , p := range * pools {
70- name := p .Name
71- if name == "" {
72- name = "-"
73- }
7470 tableData = append (tableData , []string {
7571 p .ID ,
76- name ,
72+ util . OrDash ( p . Name ) ,
7773 fmt .Sprintf ("%d" , p .AvailableCount ),
7874 fmt .Sprintf ("%d" , p .AcquiredCount ),
7975 util .FormatLocal (p .CreatedAt ),
@@ -125,7 +121,6 @@ func (c BrowserPoolsCmd) Create(ctx context.Context, in BrowserPoolsCreateInput)
125121 req .KioskMode = kernel .Bool (in .Kiosk .Value )
126122 }
127123
128- // Profile
129124 profile , err := buildProfileParam (in .ProfileID , in .ProfileName , in .ProfileSaveChanges )
130125 if err != nil {
131126 pterm .Error .Println (err .Error ())
@@ -139,10 +134,8 @@ func (c BrowserPoolsCmd) Create(ctx context.Context, in BrowserPoolsCreateInput)
139134 req .ProxyID = kernel .String (in .ProxyID )
140135 }
141136
142- // Extensions
143137 req .Extensions = buildExtensionsParam (in .Extensions )
144138
145- // Viewport
146139 viewport , err := buildViewportParam (in .Viewport )
147140 if err != nil {
148141 pterm .Error .Println (err .Error ())
@@ -194,21 +187,26 @@ func (c BrowserPoolsCmd) Get(ctx context.Context, in BrowserPoolsGetInput) error
194187 return nil
195188 }
196189
197- name := pool .Name
198- if name == "" {
199- name = "-"
200- }
201- tableData := pterm.TableData {
202- {"Property" , "Value" },
203- {"ID" , pool .ID },
204- {"Name" , name },
205- {"Size" , fmt .Sprintf ("%d" , pool .BrowserPoolConfig .Size )},
206- {"Available" , fmt .Sprintf ("%d" , pool .AvailableCount )},
207- {"Acquired" , fmt .Sprintf ("%d" , pool .AcquiredCount )},
208- {"Timeout" , fmt .Sprintf ("%d" , pool .BrowserPoolConfig .TimeoutSeconds )},
209- {"Created At" , util .FormatLocal (pool .CreatedAt )},
210- }
211- PrintTableNoPad (tableData , true )
190+ cfg := pool .BrowserPoolConfig
191+
192+ rows := pterm.TableData {{"Property" , "Value" }}
193+ rows = append (rows , []string {"ID" , pool .ID })
194+ rows = append (rows , []string {"Name" , util .OrDash (pool .Name )})
195+ rows = append (rows , []string {"Size" , fmt .Sprintf ("%d" , cfg .Size )})
196+ rows = append (rows , []string {"Available" , fmt .Sprintf ("%d" , pool .AvailableCount )})
197+ rows = append (rows , []string {"Acquired" , fmt .Sprintf ("%d" , pool .AcquiredCount )})
198+ rows = append (rows , []string {"Fill Rate" , formatFillRate (cfg .FillRatePerMinute )})
199+ rows = append (rows , []string {"Timeout (seconds)" , fmt .Sprintf ("%d" , cfg .TimeoutSeconds )})
200+ rows = append (rows , []string {"Headless" , fmt .Sprintf ("%t" , cfg .Headless )})
201+ rows = append (rows , []string {"Stealth" , fmt .Sprintf ("%t" , cfg .Stealth )})
202+ rows = append (rows , []string {"Kiosk Mode" , fmt .Sprintf ("%t" , cfg .KioskMode )})
203+ rows = append (rows , []string {"Profile" , formatProfile (cfg .Profile )})
204+ rows = append (rows , []string {"Proxy ID" , util .OrDash (cfg .ProxyID )})
205+ rows = append (rows , []string {"Extensions" , formatExtensions (cfg .Extensions )})
206+ rows = append (rows , []string {"Viewport" , formatViewport (cfg .Viewport )})
207+ rows = append (rows , []string {"Created At" , util .FormatLocal (pool .CreatedAt )})
208+
209+ PrintTableNoPad (rows , true )
212210 return nil
213211}
214212
@@ -258,7 +256,6 @@ func (c BrowserPoolsCmd) Update(ctx context.Context, in BrowserPoolsUpdateInput)
258256 req .DiscardAllIdle = kernel .Bool (in .DiscardAllIdle .Value )
259257 }
260258
261- // Profile
262259 profile , err := buildProfileParam (in .ProfileID , in .ProfileName , in .ProfileSaveChanges )
263260 if err != nil {
264261 pterm .Error .Println (err .Error ())
@@ -272,10 +269,8 @@ func (c BrowserPoolsCmd) Update(ctx context.Context, in BrowserPoolsUpdateInput)
272269 req .ProxyID = kernel .String (in .ProxyID )
273270 }
274271
275- // Extensions
276272 req .Extensions = buildExtensionsParam (in .Extensions )
277273
278- // Viewport
279274 viewport , err := buildViewportParam (in .Viewport )
280275 if err != nil {
281276 pterm .Error .Println (err .Error ())
@@ -450,10 +445,8 @@ var browserPoolsFlushCmd = &cobra.Command{
450445}
451446
452447func init () {
453- // list flags
454448 browserPoolsListCmd .Flags ().StringP ("output" , "o" , "" , "Output format: json for raw API response" )
455449
456- // create flags
457450 browserPoolsCreateCmd .Flags ().String ("name" , "" , "Optional unique name for the pool" )
458451 browserPoolsCreateCmd .Flags ().Int64 ("size" , 0 , "Number of browsers in the pool" )
459452 _ = browserPoolsCreateCmd .MarkFlagRequired ("size" )
@@ -469,10 +462,8 @@ func init() {
469462 browserPoolsCreateCmd .Flags ().StringSlice ("extension" , []string {}, "Extension IDs or names" )
470463 browserPoolsCreateCmd .Flags ().String ("viewport" , "" , "Viewport size (e.g. 1280x800)" )
471464
472- // get flags
473465 browserPoolsGetCmd .Flags ().StringP ("output" , "o" , "" , "Output format: json for raw API response" )
474466
475- // update flags
476467 browserPoolsUpdateCmd .Flags ().String ("name" , "" , "Update the pool name" )
477468 browserPoolsUpdateCmd .Flags ().Int64 ("size" , 0 , "Number of browsers in the pool" )
478469 browserPoolsUpdateCmd .Flags ().Int64 ("fill-rate" , 0 , "Fill rate per minute" )
@@ -488,13 +479,10 @@ func init() {
488479 browserPoolsUpdateCmd .Flags ().String ("viewport" , "" , "Viewport size (e.g. 1280x800)" )
489480 browserPoolsUpdateCmd .Flags ().Bool ("discard-all-idle" , false , "Discard all idle browsers" )
490481
491- // delete flags
492482 browserPoolsDeleteCmd .Flags ().Bool ("force" , false , "Force delete even if browsers are leased" )
493483
494- // acquire flags
495484 browserPoolsAcquireCmd .Flags ().Int64 ("timeout" , 0 , "Acquire timeout in seconds" )
496485
497- // release flags
498486 browserPoolsReleaseCmd .Flags ().String ("session-id" , "" , "Browser session ID to release" )
499487 _ = browserPoolsReleaseCmd .MarkFlagRequired ("session-id" )
500488 browserPoolsReleaseCmd .Flags ().Bool ("reuse" , true , "Reuse the browser instance" )
@@ -692,3 +680,42 @@ func buildViewportParam(viewport string) (*kernel.BrowserViewportParam, error) {
692680 }
693681 return & vp , nil
694682}
683+
684+ func formatFillRate (rate int64 ) string {
685+ if rate > 0 {
686+ return fmt .Sprintf ("%d%%" , rate )
687+ }
688+ return "-"
689+ }
690+
691+ func formatProfile (profile kernel.BrowserProfile ) string {
692+ name := util .FirstOrDash (profile .Name , profile .ID )
693+ if name == "-" {
694+ return "-"
695+ }
696+ if profile .SaveChanges {
697+ return fmt .Sprintf ("%s (save changes: true)" , name )
698+ }
699+ return fmt .Sprintf ("%s (save changes: false)" , name )
700+ }
701+
702+ func formatExtensions (extensions []kernel.BrowserExtension ) string {
703+ var names []string
704+ for _ , ext := range extensions {
705+ if name := util .FirstOrDash (ext .Name , ext .ID ); name != "-" {
706+ names = append (names , name )
707+ }
708+ }
709+ return util .JoinOrDash (names ... )
710+ }
711+
712+ func formatViewport (viewport kernel.BrowserViewport ) string {
713+ if viewport .Width == 0 || viewport .Height == 0 {
714+ return "-"
715+ }
716+ s := fmt .Sprintf ("%dx%d" , viewport .Width , viewport .Height )
717+ if viewport .RefreshRate > 0 {
718+ s += fmt .Sprintf ("@%d" , viewport .RefreshRate )
719+ }
720+ return s
721+ }
0 commit comments