| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 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 |
|
| 28 |
|
| 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 |
} |