@@ -453,11 +453,22 @@ func printVolumes(d *DryccCmd, volumes api.Volumes) {
453453 table .Render ()
454454}
455455
456- func (d * DryccCmd ) newProgressbar (maxBytes int64 , icon , description string ) * progressbar.ProgressBar {
457- description = fmt .Sprintf ("%-32s" , description )
458- if len (description ) > 32 {
459- description = fmt .Sprintf ("...%s" , description [len (description )- 29 :])
456+ // fixateBarDescription - fancify bar description based on the terminal width.
457+ func (d * DryccCmd ) fixateBarDescription (description string , width int ) string {
458+ switch {
459+ case len (description ) > width :
460+ // Trim caption to fit within the screen
461+ trimSize := len (description ) - width + 3
462+ if trimSize < len (description ) {
463+ description = "..." + description [trimSize :]
464+ }
465+ case len (description ) < width :
466+ description += strings .Repeat (" " , width - len (description ))
460467 }
468+ return description
469+ }
470+
471+ func (d * DryccCmd ) newProgressbar (maxBytes int64 , icon , description string ) * progressbar.ProgressBar {
461472 return progressbar .NewOptions64 (
462473 maxBytes ,
463474 progressbar .OptionSetDescription (description ),
@@ -471,7 +482,7 @@ func (d *DryccCmd) newProgressbar(maxBytes int64, icon, description string) *pro
471482 progressbar .OptionSpinnerType (14 ),
472483 progressbar .OptionFullWidth (),
473484 progressbar .OptionSetRenderBlankState (true ),
474- progressbar .OptionSetDescription (fmt .Sprintf ("[cyan][%s][reset] %s" , icon , description )),
485+ progressbar .OptionSetDescription (fmt .Sprintf ("[cyan][%s][reset] %s" , icon , d . fixateBarDescription ( description , 32 ) )),
475486 progressbar .OptionSetTheme (progressbar.Theme {
476487 Saucer : "[green]=[reset]" ,
477488 SaucerHead : "[green]>[reset]" ,
0 commit comments