@@ -142,23 +142,29 @@ type WgoCmd struct {
142142// by "wgo" indicates a new WgoCmd.
143143func WgoCommands (ctx context.Context , args []string ) ([]* WgoCmd , error ) {
144144 var wgoCmds []* WgoCmd
145- i , j , num := 1 , 1 , 1
145+ i , j , wgoNumber := 1 , 1 , 1
146146 for j < len (args ) {
147147 if args [j ] != "::" || j + 1 >= len (args ) || args [j + 1 ] != "wgo" {
148148 j ++
149149 continue
150150 }
151- wgoCmd , err := WgoCommand (ctx , args [i :j ])
151+ wgoCmd , err := WgoCommand (ctx , wgoNumber , args [i :j ])
152152 if err != nil {
153- return nil , fmt .Errorf ("[wgo %d] %w" , num , err )
153+ if wgoNumber > 1 {
154+ return nil , fmt .Errorf ("[wgo%d] %w" , wgoNumber , err )
155+ }
156+ return nil , fmt .Errorf ("[wgo] %w" , err )
154157 }
155158 wgoCmds = append (wgoCmds , wgoCmd )
156- i , j , num = j + 2 , j + 2 , num + 1
159+ i , j , wgoNumber = j + 2 , j + 2 , wgoNumber + 1
157160 }
158161 if j > i {
159- wgoCmd , err := WgoCommand (ctx , args [i :j ])
162+ wgoCmd , err := WgoCommand (ctx , wgoNumber , args [i :j ])
160163 if err != nil {
161- return nil , fmt .Errorf ("[wgo %d] %w" , num , err )
164+ if wgoNumber > 1 {
165+ return nil , fmt .Errorf ("[wgo%d] %w" , wgoNumber , err )
166+ }
167+ return nil , fmt .Errorf ("[wgo] %w" , err )
162168 }
163169 wgoCmds = append (wgoCmds , wgoCmd )
164170 }
@@ -167,7 +173,7 @@ func WgoCommands(ctx context.Context, args []string) ([]*WgoCmd, error) {
167173
168174// WgoCommand instantiates a new WgoCmd. Each "::" separator indicates a new
169175// chained command.
170- func WgoCommand (ctx context.Context , args []string ) (* WgoCmd , error ) {
176+ func WgoCommand (ctx context.Context , wgoNumber int , args []string ) (* WgoCmd , error ) {
171177 cwd , err := os .Getwd ()
172178 if err != nil {
173179 return nil , err
@@ -278,7 +284,11 @@ Flags:
278284 return nil , err
279285 }
280286 if verbose {
281- wgoCmd .Logger = log .New (os .Stderr , "[wgo] " , 0 )
287+ if wgoNumber > 1 {
288+ wgoCmd .Logger = log .New (os .Stderr , fmt .Sprintf ("[wgo%d] " , wgoNumber ), 0 )
289+ } else {
290+ wgoCmd .Logger = log .New (os .Stderr , "[wgo] " , 0 )
291+ }
282292 }
283293 if debounce == "" {
284294 wgoCmd .Debounce = 300 * time .Millisecond
0 commit comments