forked from kcl-lang/kpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kpm.go
59 lines (54 loc) · 1.28 KB
/
kpm.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
// Copyright 2022 The KCL Authors. All rights reserved.
package main
import (
"os"
"github.com/urfave/cli/v2"
"kcl-lang.io/kpm/pkg/client"
"kcl-lang.io/kpm/pkg/cmd"
"kcl-lang.io/kpm/pkg/reporter"
"kcl-lang.io/kpm/pkg/version"
)
func main() {
reporter.InitReporter()
kpmcli, err := client.NewKpmClient()
if err != nil {
reporter.Fatal(err)
}
app := cli.NewApp()
app.Name = "kpm"
app.Usage = "kpm is a kcl package manager"
app.Version = version.GetVersionInStr()
app.UsageText = "kpm <command> [arguments]..."
app.Commands = []*cli.Command{
cmd.NewInitCmd(kpmcli),
cmd.NewGraphCmd(kpmcli),
cmd.NewAddCmd(kpmcli),
cmd.NewPkgCmd(kpmcli),
cmd.NewMetadataCmd(kpmcli),
cmd.NewImportCmd(kpmcli),
// todo: The following commands are bound to the oci registry.
// Refactor them to compatible with the other registry.
cmd.NewRunCmd(kpmcli),
cmd.NewLoginCmd(kpmcli),
cmd.NewLogoutCmd(kpmcli),
cmd.NewPushCmd(kpmcli),
cmd.NewPullCmd(kpmcli),
cmd.NewUpdateCmd(kpmcli),
}
app.Flags = []cli.Flag{
&cli.BoolFlag{
Name: cmd.FLAG_QUIET,
Usage: "push in vendor mode",
},
}
app.Before = func(c *cli.Context) error {
if c.Bool(cmd.FLAG_QUIET) {
kpmcli.SetLogWriter(nil)
}
return nil
}
err = app.Run(os.Args)
if err != nil {
reporter.Fatal(err)
}
}