This repository has been archived by the owner on Aug 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
qpm.go
74 lines (56 loc) · 1.75 KB
/
qpm.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
71
72
73
74
// Copyright 2015 Cutehacks AS. All rights reserved.
// License can be found in the LICENSE file.
package main
import (
"flag"
"fmt"
"os"
cmd "qpm.io/qpm/commands"
"qpm.io/qpm/core"
)
var registry *CommandRegistry
func Usage() {
fmt.Println(`
qpm is a tool for managing Qt dependencies
Usage:
qpm COMMAND [args]`)
registry.CommandUsage()
fmt.Printf("qpm@%s (built from %s)\n\n", core.Version, core.Build)
}
func main() {
ctx := *core.NewContext()
// Register new sub-commands here
registry = NewCommandRegistry()
registry.RegisterSubCommand("ping", cmd.NewPingCommand(ctx))
registry.RegisterSubCommand("init", cmd.NewInitCommand(ctx))
registry.RegisterSubCommand("search", cmd.NewSearchCommand(ctx))
registry.RegisterSubCommand("list", cmd.NewListCommand(ctx))
registry.RegisterSubCommand("info", cmd.NewInfoCommand(ctx))
registry.RegisterSubCommand("install", cmd.NewInstallCommand(ctx))
registry.RegisterSubCommand("uninstall", cmd.NewUninstallCommand(ctx))
registry.RegisterSubCommand("publish", cmd.NewPublishCommand(ctx))
registry.RegisterSubCommand("help", cmd.NewHelpCommand(ctx))
registry.RegisterSubCommand("check", cmd.NewCheckCommand(ctx))
registry.RegisterSubCommand("sign", cmd.NewSignCommand(ctx))
registry.RegisterSubCommand("verify", cmd.NewVerifyCommand(ctx))
//registry.RegisterSubCommand("deprecate", cmd.NewDeprecateCommand(ctx))
//registry.RegisterSubCommand("prune", cmd.NewPruneCommand(ctx))
if len(os.Args) < 2 {
Usage()
return
}
subCmd := os.Args[1]
if !registry.Exists(subCmd) {
Usage()
return
}
command := registry.Get(subCmd)
fs := flag.NewFlagSet(os.Args[0], flag.ExitOnError)
fs.Usage = func() {
Usage()
fs.PrintDefaults()
}
command.RegisterFlags(fs)
fs.Parse(os.Args[2:])
command.Run()
}