@@ -15,19 +15,39 @@ var InfoHeader = Str{
1515 Fancy : aec .Bold .Apply (aec .LightCyanB .Apply (aec .BlackF .Apply ("i" )) + " " + aec .LightCyanF .Apply ("Info → " )),
1616}
1717
18- func (o Output ) PrintNote (format string , args ... any ) {
18+ type options struct {
19+ header Str
20+ }
21+
22+ type noteOptions func (o * options )
23+
24+ func withHeader (header Str ) noteOptions {
25+ return func (o * options ) {
26+ o .header = header
27+ }
28+ }
29+
30+ func (o Output ) printNoteWithOptions (format string , args []any , opts ... noteOptions ) {
1931 if o .isTerminal {
2032 // TODO: Handle all flags
2133 format = strings .ReplaceAll (format , "--platform" , ColorFlag .Apply ("--platform" ))
2234 }
2335
24- header := o .Sprint (InfoHeader )
36+ opt := & options {
37+ header : InfoHeader ,
38+ }
39+
40+ for _ , override := range opts {
41+ override (opt )
42+ }
43+
44+ h := o .Sprint (opt .header )
2545
26- _ , _ = fmt .Fprint (o , "\n " , header )
46+ _ , _ = fmt .Fprint (o , "\n " , h )
2747 s := fmt .Sprintf (format , args ... )
2848 for idx , line := range strings .Split (s , "\n " ) {
2949 if idx > 0 {
30- _ , _ = fmt .Fprint (o , strings .Repeat (" " , Width (header )))
50+ _ , _ = fmt .Fprint (o , strings .Repeat (" " , Width (h )))
3151 }
3252
3353 l := line
@@ -37,3 +57,16 @@ func (o Output) PrintNote(format string, args ...any) {
3757 _ , _ = fmt .Fprintln (o , l )
3858 }
3959}
60+
61+ func (o Output ) PrintNote (format string , args ... any ) {
62+ o .printNoteWithOptions (format , args , withHeader (InfoHeader ))
63+ }
64+
65+ var warningHeader = Str {
66+ Plain : " Warn -> " ,
67+ Fancy : aec .Bold .Apply (aec .LightYellowB .Apply (aec .BlackF .Apply ("w" )) + " " + ColorWarning .Apply ("Warn → " )),
68+ }
69+
70+ func (o Output ) PrintWarning (format string , args ... any ) {
71+ o .printNoteWithOptions (format , args , withHeader (warningHeader ))
72+ }
0 commit comments