-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (32 loc) · 1.03 KB
/
main.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
package main
import (
"flag"
"fmt"
"os"
"github.com/sirupsen/logrus"
"github.com/vpavlin/hardhat-abigen/internal/extractor"
)
func main() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s [options] [FILE|DIRECTORY]\n", os.Args[0])
flag.VisitAll(func(f *flag.Flag) {
fmt.Fprintf(os.Stderr, " --%s\n\t %v (default: '%s')\n", f.Name, f.Usage, f.DefValue) // f.Name, f.Value
})
}
outDir := flag.String("outDir", "output", "Destination directory for extracted ABI json files and generated bindings")
generateBindings := flag.Bool("bindings", true, "Use Abigen to generate bindings")
exclude := flag.String("exclude", "", "List of strings to match aginst paths to exclude them from processing")
flag.Parse()
inFile := flag.Arg(0)
info, err := os.Stat(inFile)
if err != nil {
logrus.Errorf("No file provided")
flag.Usage()
os.Exit(1)
}
if info.IsDir() {
extractor.ProcessAll(inFile, *outDir, *generateBindings, *exclude)
} else {
extractor.ProcessSingle(inFile, *outDir, *generateBindings, *exclude)
}
}