github.com/docker/app@v0.9.1-beta3.0.20210611140623-a48f773ab002/internal/commands/init.go (about) 1 package commands 2 3 import ( 4 "fmt" 5 6 "github.com/docker/app/internal/packager" 7 "github.com/docker/cli/cli" 8 "github.com/docker/cli/cli/command" 9 "github.com/spf13/cobra" 10 ) 11 12 var ( 13 initComposeFile string 14 ) 15 16 const initExample = `- $ docker app init myapp 17 - $ docker app init myapp --compose-file docker-compose.yml` 18 19 func initCmd(dockerCli command.Cli) *cobra.Command { 20 cmd := &cobra.Command{ 21 Use: "init [OPTIONS] APP_DEFINITION", 22 Short: "Initialize an App definition", 23 Example: initExample, 24 Args: cli.ExactArgs(1), 25 RunE: func(cmd *cobra.Command, args []string) error { 26 created, err := packager.Init(dockerCli.Err(), args[0], initComposeFile) 27 if err != nil { 28 return err 29 } 30 fmt.Fprintf(dockerCli.Out(), "Created %q\n", created) 31 return nil 32 }, 33 } 34 cmd.Flags().StringVar(&initComposeFile, "compose-file", "", "Compose file to use to bootstrap a Docker App definition") 35 return cmd 36 }