MCPcopy
hub / github.com/docker/compose / versionCommand

Function versionCommand

cmd/compose/version.go:35–57  ·  cmd/compose/version.go::versionCommand
(dockerCli command.Cli)

Source from the content-addressed store, hash-verified

33}
34
35func versionCommand(dockerCli command.Cli) *cobra.Command {
36 opts := versionOptions{}
37 cmd := &cobra.Command{
38 Use: "version [OPTIONS]",
39 Short: "Show the Docker Compose version information",
40 Args: cobra.NoArgs,
41 RunE: func(cmd *cobra.Command, _ []string) error {
42 runVersion(opts, dockerCli)
43 return nil
44 },
45 PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
46 // overwrite parent PersistentPreRunE to avoid trying to load
47 // compose file on version command if COMPOSE_FILE is set
48 return nil
49 },
50 }
51 // define flags for backward compatibility with com.docker.cli
52 flags := cmd.Flags()
53 flags.StringVarP(&opts.format, "format", "f", "", "Format the output. Values: [pretty | json]. (Default: pretty)")
54 flags.BoolVar(&opts.short, "short", false, "Shows only Compose's version number")
55
56 return cmd
57}
58
59func runVersion(opts versionOptions, dockerCli command.Cli) {
60 if opts.short {

Callers 2

TestVersionCommandFunction · 0.85
RootCommandFunction · 0.85

Calls 1

runVersionFunction · 0.85

Tested by 1

TestVersionCommandFunction · 0.68