| 35 | ) |
| 36 | |
| 37 | func pluginMain() { |
| 38 | plugin.Run( |
| 39 | func(cli command.Cli) *cobra.Command { |
| 40 | backendOptions := &commands.BackendOptions{ |
| 41 | Options: []compose.Option{ |
| 42 | compose.WithPrompt(prompt.NewPrompt(cli.In(), cli.Out()).Confirm), |
| 43 | }, |
| 44 | } |
| 45 | |
| 46 | cmd := commands.RootCommand(cli, backendOptions) |
| 47 | cmd.AddCommand(commands.HooksCommand()) |
| 48 | originalPreRunE := cmd.PersistentPreRunE |
| 49 | cmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error { |
| 50 | // initialize the cli instance |
| 51 | if err := plugin.PersistentPreRunE(cmd, args); err != nil { |
| 52 | return err |
| 53 | } |
| 54 | if err := cmdtrace.Setup(cmd, cli, os.Args[1:]); err != nil { |
| 55 | logrus.Debugf("failed to enable tracing: %v", err) |
| 56 | } |
| 57 | |
| 58 | if originalPreRunE != nil { |
| 59 | return originalPreRunE(cmd, args) |
| 60 | } |
| 61 | return nil |
| 62 | } |
| 63 | |
| 64 | cmd.SetFlagErrorFunc(func(c *cobra.Command, err error) error { |
| 65 | return dockercli.StatusError{ |
| 66 | StatusCode: 1, |
| 67 | Status: err.Error(), |
| 68 | } |
| 69 | }) |
| 70 | return cmd |
| 71 | }, |
| 72 | metadata.Metadata{ |
| 73 | SchemaVersion: "0.1.0", |
| 74 | Vendor: "Docker Inc.", |
| 75 | Version: internal.Version, |
| 76 | }, |
| 77 | command.WithUserAgent("compose/"+internal.Version), |
| 78 | ) |
| 79 | } |
| 80 | |
| 81 | func main() { |
| 82 | if plugin.RunningStandalone() { |