2017-06-08 18:17:44 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/Sirupsen/logrus"
|
2017-06-22 20:15:46 +00:00
|
|
|
"github.com/moby/buildkit/client"
|
2017-06-08 18:17:44 +00:00
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := cli.NewApp()
|
|
|
|
app.Name = "buildctl"
|
|
|
|
app.Usage = "build utility"
|
|
|
|
|
|
|
|
app.Flags = []cli.Flag{
|
|
|
|
cli.BoolFlag{
|
|
|
|
Name: "debug",
|
|
|
|
Usage: "enable debug output in logs",
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "socket",
|
|
|
|
Usage: "listening socket",
|
|
|
|
Value: "/run/buildkit/buildd.sock",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
app.Commands = []cli.Command{
|
|
|
|
diskUsageCommand,
|
2017-06-09 01:16:19 +00:00
|
|
|
buildCommand,
|
2017-06-13 08:09:14 +00:00
|
|
|
debugCommand,
|
2017-06-08 18:17:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
app.Before = func(context *cli.Context) error {
|
|
|
|
if context.GlobalBool("debug") {
|
|
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "buildd: %s\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func resolveClient(c *cli.Context) (*client.Client, error) {
|
2017-06-19 20:39:00 +00:00
|
|
|
return client.New(c.GlobalString("socket"), client.WithBlock())
|
2017-06-08 18:17:44 +00:00
|
|
|
}
|