-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmain.go
70 lines (63 loc) · 1.43 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"context"
"fmt"
"os"
"github.com/urfave/cli/v3"
"go.bytecodealliance.org/cmd/wit-bindgen-go/cmd/generate"
"go.bytecodealliance.org/cmd/wit-bindgen-go/cmd/wit"
"go.bytecodealliance.org/internal/module"
)
func main() {
err := Command.Run(context.Background(), os.Args)
if err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
os.Exit(1)
}
}
var Command = &cli.Command{
Name: "wit-bindgen-go",
Usage: "inspect or manipulate WebAssembly Interface Types for Go",
Commands: []*cli.Command{
generate.Command,
wit.Command,
version,
},
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "version",
Usage: "print the version",
HideDefault: true,
Local: true,
},
&cli.BoolFlag{
Name: "force-wit",
Usage: "force loading WIT via wasm-tools",
},
&cli.BoolFlag{
Name: "verbose",
Aliases: []string{"v"},
Usage: "print verbose logging messages",
},
&cli.BoolFlag{
Name: "debug",
Aliases: []string{"vv"},
Usage: "print debug logging messages",
},
},
Action: action,
}
func action(ctx context.Context, cmd *cli.Command) error {
if cmd.Bool("version") {
return version.Run(ctx, nil)
}
return cli.ShowAppHelp(cmd)
}
var version = &cli.Command{
Name: "version",
Usage: "print the version",
Action: func(ctx context.Context, cmd *cli.Command) error {
fmt.Fprintf(cmd.Writer, "%s version %s\n", cmd.Root().Name, module.Version())
return nil
},
}