@@ -125,10 +125,19 @@ func wrap(width int, s string) string {
125125 return wordwrap .WrapString (s , uint (width ))
126126}
127127
128+ // A string with n spaces
129+ func indentStr (n int ) string {
130+ return strings .Repeat (" " , n )
131+ }
132+
133+ // Indent a certain number of spaces
134+ func indent (n int , s string ) string {
135+ return indentStr (n ) + s
136+ }
137+
128138// Indent with spaces and also wrap
129- func indentWrap (indent int , width int , s string ) string {
130- indentStr := strings .Repeat (" " , indent )
131- return indentStr + strings .ReplaceAll (wrap (width - indent , s ), "\n " , "\n " + indentStr )
139+ func indentWrap (n int , width int , s string ) string {
140+ return indent (n , strings .ReplaceAll (wrap (width - n , s ), "\n " , "\n " + indentStr (n )))
132141}
133142
134143// A way to assemble a map from keys and values in a template
@@ -148,8 +157,8 @@ func toMap(values ...interface{}) (map[string]interface{}, error) {
148157}
149158
150159// Can make it easier to get the right number of line breaks
151- func nl () ( string , error ) {
152- return "\n " , nil
160+ func nl () string {
161+ return "\n "
153162}
154163
155164// For use in template.Funcs above
@@ -159,6 +168,7 @@ var templateHelpers = template.FuncMap{
159168 "indicator" : indicator ,
160169 "colorIndicator" : colorIndicator ,
161170 "wrap" : wrap ,
171+ "indent" : indent ,
162172 "indentWrap" : indentWrap ,
163173 "toMap" : toMap ,
164174 "nl" : nl ,
0 commit comments