@@ -516,6 +516,7 @@ func (s *helpPrinter) printFlag(ctx context.Context, sb *strings.Builder, verbos
516
516
tg := ff .ToggleGroupLeadHelpString ()
517
517
def , defPlain := ff .DefaultValueHelpString (trans , CurrentDefaultValueColor , CurrentDescColor )
518
518
dep , depPlain := ff .DeprecatedHelpString (trans , CurrentDeprecatedColor , CurrentDescColor )
519
+ env , envPlain := ff .EnvVarsHelpString (trans , CurrentEnvVarsColor , CurrentDescColor )
519
520
520
521
if (ff .Hidden () && * verboseCount > 0 ) || (ff .VendorHidden () && * verboseCount >= 3 ) { //nolint:revive
521
522
s .WriteBgColor (sb , color .BgDim )
@@ -547,7 +548,7 @@ func (s *helpPrinter) printFlag(ctx context.Context, sb *strings.Builder, verbos
547
548
if right != "" {
548
549
s .WriteColor (sb , CurrentDescColor )
549
550
550
- _ , l , l1st := len (right ), len (right )+ len (defPlain )+ len (depPlain ), len (tg )
551
+ _ , l , l1st := len (right ), len (right )+ len (defPlain )+ len (depPlain )+ len ( envPlain ) , len (tg )
551
552
// aa := []string{}
552
553
if l + l1st >= rCols {
553
554
var prt string
@@ -584,12 +585,28 @@ func (s *helpPrinter) printFlag(ctx context.Context, sb *strings.Builder, verbos
584
585
printed += 4
585
586
}
586
587
588
+ if env != "" && printed >= 0 {
589
+ if split {
590
+ envlen := len (envPlain )
591
+ printed += envlen
592
+ if printed >= rCols {
593
+ printleftpad (split )
594
+ printed = envlen
595
+ }
596
+ }
597
+ if sb .String ()[sb .Len ()- 1 ] != ' ' {
598
+ _ , _ = sb .WriteString (" " )
599
+ }
600
+ _ , _ = sb .WriteString (env )
601
+ }
602
+
587
603
if def != "" && printed >= 0 {
588
604
if split {
589
- deflen := len (is .StripEscapes (def ))
605
+ deflen := len (defPlain ) // len( is.StripEscapes(def))
590
606
printed += deflen
591
607
if printed >= rCols {
592
608
printleftpad (split )
609
+ printed = deflen
593
610
}
594
611
}
595
612
if sb .String ()[sb .Len ()- 1 ] != ' ' {
@@ -600,10 +617,11 @@ func (s *helpPrinter) printFlag(ctx context.Context, sb *strings.Builder, verbos
600
617
601
618
if dep != "" {
602
619
if split {
603
- deplen := len (is .StripEscapes (dep ))
620
+ deplen := len (depPlain ) // len( is.StripEscapes(dep))
604
621
printed += deplen
605
622
if printed >= rCols {
606
623
printleftpad (split )
624
+ printed = deplen
607
625
}
608
626
}
609
627
if sb .String ()[sb .Len ()- 1 ] != ' ' {
@@ -657,6 +675,8 @@ var (
657
675
// CurrentDeprecatedColor the print color for deprecated opt line
658
676
CurrentDeprecatedColor = color .FgDarkGray
659
677
678
+ CurrentEnvVarsColor = color .FgLightGray
679
+
660
680
// CurrentDescColor the print color for description line
661
681
CurrentDescColor = color .FgDarkGray
662
682
// CurrentDefaultValueColor the print color for default value line
0 commit comments