@@ -3,64 +3,102 @@ package cmd
3
3
import (
4
4
"fmt"
5
5
"strconv"
6
+ "strings"
6
7
7
8
"github.com/nektos/act/pkg/model"
8
9
)
9
10
10
11
func printList (plan * model.Plan ) error {
11
12
type lineInfoDef struct {
12
- id string
13
- stage string
14
- name string
13
+ jobID string
14
+ jobName string
15
+ stage string
16
+ wfName string
17
+ wfFile string
18
+ events string
15
19
}
16
20
lineInfos := []lineInfoDef {}
17
21
18
22
header := lineInfoDef {
19
- id : "ID" ,
20
- stage : "Stage" ,
21
- name : "Name" ,
23
+ jobID : "Job ID" ,
24
+ jobName : "Job name" ,
25
+ stage : "Stage" ,
26
+ wfName : "Workflow name" ,
27
+ wfFile : "Workflow file" ,
28
+ events : "Events" ,
22
29
}
23
30
24
31
jobs := map [string ]bool {}
25
32
duplicateJobIDs := false
26
33
27
- idMaxWidth := len (header .id )
34
+ jobIDMaxWidth := len (header .jobID )
35
+ jobNameMaxWidth := len (header .jobName )
28
36
stageMaxWidth := len (header .stage )
29
- nameMaxWidth := len (header .name )
37
+ wfNameMaxWidth := len (header .wfName )
38
+ wfFileMaxWidth := len (header .wfFile )
39
+ eventsMaxWidth := len (header .events )
30
40
31
41
for i , stage := range plan .Stages {
32
42
for _ , r := range stage .Runs {
33
43
jobID := r .JobID
34
44
line := lineInfoDef {
35
- id : jobID ,
36
- stage : strconv .Itoa (i ),
37
- name : r .String (),
45
+ jobID : jobID ,
46
+ jobName : r .String (),
47
+ stage : strconv .Itoa (i ),
48
+ wfName : r .Workflow .Name ,
49
+ wfFile : r .Workflow .File ,
50
+ events : strings .Join (r .Workflow .On (), `,` ),
38
51
}
39
52
if _ , ok := jobs [jobID ]; ok {
40
53
duplicateJobIDs = true
41
54
} else {
42
55
jobs [jobID ] = true
43
56
}
44
57
lineInfos = append (lineInfos , line )
45
- if idMaxWidth < len (line .id ) {
46
- idMaxWidth = len (line .id )
58
+ if jobIDMaxWidth < len (line .jobID ) {
59
+ jobIDMaxWidth = len (line .jobID )
60
+ }
61
+ if jobNameMaxWidth < len (line .jobName ) {
62
+ jobNameMaxWidth = len (line .jobName )
47
63
}
48
64
if stageMaxWidth < len (line .stage ) {
49
65
stageMaxWidth = len (line .stage )
50
66
}
51
- if nameMaxWidth < len (line .name ) {
52
- nameMaxWidth = len (line .name )
67
+ if wfNameMaxWidth < len (line .wfName ) {
68
+ wfNameMaxWidth = len (line .wfName )
69
+ }
70
+ if wfFileMaxWidth < len (line .wfFile ) {
71
+ wfFileMaxWidth = len (line .wfFile )
72
+ }
73
+ if eventsMaxWidth < len (line .events ) {
74
+ eventsMaxWidth = len (line .events )
53
75
}
54
76
}
55
77
}
56
78
57
- idMaxWidth += 2
79
+ jobIDMaxWidth += 2
80
+ jobNameMaxWidth += 2
58
81
stageMaxWidth += 2
59
- nameMaxWidth += 2
82
+ wfNameMaxWidth += 2
83
+ wfFileMaxWidth += 2
60
84
61
- fmt .Printf ("%*s%*s%*s\n " , - idMaxWidth , header .id , - stageMaxWidth , header .stage , - nameMaxWidth , header .name )
85
+ fmt .Printf ("%*s%*s%*s%*s%*s%*s\n " ,
86
+ - stageMaxWidth , header .stage ,
87
+ - jobIDMaxWidth , header .jobID ,
88
+ - jobNameMaxWidth , header .jobName ,
89
+ - wfNameMaxWidth , header .wfName ,
90
+ - wfFileMaxWidth , header .wfFile ,
91
+ - eventsMaxWidth , header .events ,
92
+ )
62
93
for _ , line := range lineInfos {
63
- fmt .Printf ("%*s%*s%*s\n " , - idMaxWidth , line .id , - stageMaxWidth , line .stage , - nameMaxWidth , line .name )
94
+ fmt .Printf ("%*s%*s%*s%*s%*s%*s\n " ,
95
+ - stageMaxWidth , line .stage ,
96
+ - jobIDMaxWidth , line .jobID ,
97
+ - jobNameMaxWidth , line .jobName ,
98
+ - wfNameMaxWidth , line .wfName ,
99
+ - wfFileMaxWidth , line .wfFile ,
100
+ - eventsMaxWidth , line .events ,
101
+ )
64
102
}
65
103
if duplicateJobIDs {
66
104
fmt .Print ("\n Detected multiple jobs with the same job name, use `-W` to specify the path to the specific workflow.\n " )
0 commit comments