MCPcopy Create free account
hub / github.com/containerd/nerdctl / versionAction

Function versionAction

cmd/nerdctl/compose/compose_version.go:45–69  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

43}
44
45func versionAction(cmd *cobra.Command, args []string) error {
46 short, err := cmd.Flags().GetBool("short")
47 if err != nil {
48 return err
49 }
50 if short {
51 fmt.Fprintln(cmd.OutOrStdout(), strings.TrimPrefix(version.GetVersion(), "v"))
52 return nil
53 }
54
55 format, err := cmd.Flags().GetString("format")
56 if err != nil {
57 return err
58 }
59 switch format {
60 case "pretty":
61 fmt.Fprintln(cmd.OutOrStdout(), "nerdctl Compose version "+version.GetVersion())
62 case "json":
63 fmt.Fprintf(cmd.OutOrStdout(), "{\"version\":\"%v\"}\n", version.Version)
64 default:
65 return fmt.Errorf("format can be either pretty or json, not %v", format)
66 }
67
68 return nil
69}

Callers

nothing calls this directly

Calls 1

GetVersionFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…