bust/pkg/cli/cli.go

36 lines
679 B
Go
Raw Normal View History

2022-10-29 18:32:51 +02:00
package cli
2022-10-29 18:00:16 +02:00
import (
2022-10-29 18:15:55 +02:00
"context"
2022-10-29 18:00:16 +02:00
"log"
"github.com/spf13/cobra"
)
2022-10-29 18:15:55 +02:00
func Build(requirementsf func(*cobra.Command), buildf func(ctx context.Context) error) *cobra.Command {
2022-10-29 18:00:16 +02:00
var (
imageTag string
)
cmd := &cobra.Command{
Use: "build",
RunE: func(cmd *cobra.Command, args []string) error {
if err := cmd.ParseFlags(args); err != nil {
return err
}
if imageTag != "" {
log.Printf("Building image: %s\n", imageTag)
}
2022-10-29 18:15:55 +02:00
return buildf(cmd.Context())
2022-10-29 18:00:16 +02:00
},
}
cmd.PersistentFlags().StringVar(&imageTag, "image-tag", "", "the url for which to tag the docker image, defaults to private url, with repo as image name")
2022-10-29 18:15:55 +02:00
requirementsf(cmd)
2022-10-29 18:00:16 +02:00
return cmd
}