-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.go
46 lines (36 loc) · 890 Bytes
/
cli.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"fmt"
"github.com/spf13/cobra"
)
func main() {
var (
old string
new string
opts Options
)
command := &cobra.Command{
Use: "rpcdiff",
Short: "use rpcdiff to compare two openrpc schemas",
Version: "0.0.0",
FParseErrWhitelist: cobra.FParseErrWhitelist{
UnknownFlags: true,
},
Run: func(cmd *cobra.Command, args []string) {
diff, err := NewDiff(old, new, opts)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(diff.String())
},
}
flags := command.Flags()
flags.SortFlags = false
flags.StringVarP(&old, "old", "o", "", "path/url to old schema")
cobra.MarkFlagRequired(flags, "old")
flags.StringVarP(&new, "new", "n", "", "path/url to new schema")
cobra.MarkFlagRequired(flags, "new")
flags.BoolVar(&opts.ShowMeta, "compare-meta", false, "true to compare schema meta info")
command.Execute()
}