Debian Codegraph @

cmd/oci-image-tool/main.go

raw symbols SCIP
1 // Copyright 2016 The Linux Foundation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package main
16
17 import (
18 "fmt"
19 "os"
20
21 "github.com/opencontainers/image-tools/image"
22 "github.com/opencontainers/image-tools/version"
23 "github.com/sirupsen/logrus"
24 "github.com/urfave/cli"
25 )
26
27 // gitCommit will be the hash that the binary was built from
28 // and will be populated by the Makefile
29 var gitCommit = ""
30
31 func main() {
32 app := cli.NewApp()
33 app.Name = "oci-image-tool"
34 if gitCommit != "" {
35 app.Version = fmt.Sprintf("%s commit: %s", version.Version, gitCommit)
36 } else {
37 app.Version = version.Version
38 }
39 app.Usage = "OCI (Open Container Initiative) image tools"
40 app.Flags = []cli.Flag{
41 cli.BoolFlag{
42 Name: "debug",
43 Usage: "enable debug output",
44 },
45 }
46 app.Before = func(c *cli.Context) error {
47 if c.GlobalBool("debug") {
48 logrus.SetLevel(logrus.DebugLevel)
49 }
50 return nil
51 }
52 app.Commands = []cli.Command{
53 validateCommand,
54 unpackCommand,
55 createCommand,
56 }
57
58 cli.AppHelpTemplate = fmt.Sprintf(`%sMore information:
59 references %s
60 bug report %s
61 `, cli.AppHelpTemplate, image.SpecURL, image.IssuesURL)
62
63 if err := app.Run(os.Args); err != nil {
64 logrus.Fatal(err)
65 }
66 }