@@ -14,72 +14,62 @@ var permCmd = &cli.Command{
14
14
Name : "perm" ,
15
15
Flags : []cli.Flag {},
16
16
Action : func (cctx * cli.Context ) error {
17
- originMetas , err := parsePermMetas (permOption {
18
- importPath : "github.com/filecoin-project/lotus/api" ,
19
- })
20
- if err != nil {
21
- log .Fatalln ("parse lotus api interfaces:" , err )
22
- }
23
-
24
- targetMetas , err := parsePermMetas (permOption {
25
- importPath : "github.com/filecoin-project/venus/venus-shared/api/chain/v1" ,
26
- })
27
- if err != nil {
28
- log .Fatalln ("parse venus chain api interfaces:" , err )
29
- }
17
+ for _ , pair := range util .APIPairs {
18
+ originMetas , err := parsePermMetas (pair .Lotus .ParseOpt )
19
+ if err != nil {
20
+ log .Fatalln ("parse lotus api interfaces:" , err )
21
+ }
30
22
31
- originMap := map [string ]permMeta {}
32
- for _ , om := range originMetas {
33
- if om .perm != "" {
34
- originMap [om .meth ] = om
23
+ targetMetas , err := parsePermMetas (pair .Venus .ParseOpt )
24
+ if err != nil {
25
+ log .Fatalln ("parse venus chain api interfaces:" , err )
35
26
}
36
- }
37
27
38
- for _ , tm := range targetMetas {
39
- om , has := originMap [ tm . meth ]
40
- if ! has {
41
- fmt . Printf ( "%s.%s: %s <> N/A \n " , tm . iface , tm . meth , tm . perm )
42
- continue
28
+ originMap := map [ string ] permMeta {}
29
+ for _ , om := range originMetas {
30
+ if om . perm != "" {
31
+ originMap [ om . meth ] = om
32
+ }
43
33
}
44
34
45
- if tm .perm != om .perm {
46
- fmt .Printf ("%s.%s: %s <> %s.%s: %s\n " , tm .iface , tm .meth , tm .perm , om .iface , om .meth , om .perm )
35
+ fmt .Printf ("v%d: %s <> %s\n " , pair .Ver , pair .Venus .ParseOpt .ImportPath , pair .Lotus .ParseOpt .ImportPath )
36
+ for _ , tm := range targetMetas {
37
+ om , has := originMap [tm .meth ]
38
+ if ! has {
39
+ fmt .Printf ("\t - %s.%s\n " , tm .iface , tm .meth )
40
+ continue
41
+ }
42
+
43
+ if tm .perm != om .perm {
44
+ fmt .Printf ("\t > %s.%s: %s <> %s.%s: %s\n " , tm .iface , tm .meth , tm .perm , om .iface , om .meth , om .perm )
45
+ }
47
46
}
48
- }
49
47
50
- fmt .Println ()
48
+ fmt .Println ()
49
+ }
51
50
52
51
return nil
53
52
},
54
53
}
55
54
56
- type permOption struct {
57
- importPath string
58
- excluded map [string ]struct {}
59
- }
60
-
61
55
type permMeta struct {
62
56
pkg string
63
57
iface string
64
58
meth string
65
59
perm string
66
60
}
67
61
68
- func parsePermMetas (opt permOption ) ([]permMeta , error ) {
69
- ifaceMetas , err := util .ParseInterfaceMetas (opt . importPath )
62
+ func parsePermMetas (opt util. InterfaceParseOption ) ([]permMeta , error ) {
63
+ ifaceMetas , err := util .ParseInterfaceMetas (opt )
70
64
if err != nil {
71
65
return nil , err
72
66
}
73
67
74
68
var permMetas []permMeta
75
69
for _ , iface := range ifaceMetas {
76
- if _ , yes := opt .excluded [iface .Name ]; yes {
77
- continue
78
- }
79
-
80
70
for _ , ifMeth := range iface .Defined {
81
71
permMetas = append (permMetas , permMeta {
82
- pkg : opt .importPath ,
72
+ pkg : opt .ImportPath ,
83
73
iface : iface .Name ,
84
74
meth : ifMeth .Name ,
85
75
perm : getPerms (ifMeth ),
0 commit comments