Repository navigation
Expand file tree
/
Copy pathmain.go
More file actions
74 lines (63 loc) · 1.58 KB
/
Copy pathmain.go
File metadata and controls
74 lines (63 loc) · 1.58 KB
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
package main
import (
"context"
"fmt"
"log"
"os"
"strings"
"github.com/urfave/cli/v2"
"github.com/containerish/OpenRegistry/cmd/extras"
"github.com/containerish/OpenRegistry/cmd/migrations"
"github.com/containerish/OpenRegistry/cmd/registry"
)
var (
//nolint
GitCommit string
//nolint
Version string
)
func main() {
var (
projectAuthors = []*cli.Author{
{
Name: "Containerish OSS Team",
Email: "team@cntr.sh",
},
}
rootCmdFlags = []cli.Flag{
&cli.BoolFlag{Name: "validateConfig", Value: false, Usage: "--validateConfig"},
}
commands = []*cli.Command{
migrations.NewMigrationsCommand(),
registry.NewRegistryCommand(),
extras.NewExtrasCommand(),
}
)
const (
rootCmdDescription = `This CLI program can be used to manage an OpenRegistry instance.
You can perform actions such as datastore migrations, rollbacks, starting the registry server,
running OCI tests against the server, etc`
cliName = "OpenRegistry"
usage = cliName
)
app := &cli.App{
Name: cliName,
Usage: usage,
Authors: projectAuthors,
UseShortOptionHandling: true,
Suggest: true,
Version: renderVersion(),
Description: rootCmdDescription,
Flags: rootCmdFlags,
Commands: commands,
}
if err := app.RunContext(context.Background(), os.Args); err != nil {
log.Fatal(err)
}
}
func renderVersion() string {
if !strings.HasPrefix(Version, "v") {
Version = "v" + Version
}
return fmt.Sprintf(`Version: %s Commit: %s`, Version, GitCommit)
}