MCPcopy Index your code
hub / github.com/linuxkit/linuxkit / versionCmd

Function versionCmd

src/cmd/linuxkit/version.go:12–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10)
11
12func versionCmd() *cobra.Command {
13 var short, commit bool
14 cmd := &cobra.Command{
15 Use: "version",
16 Short: "report the version of linuxkit",
17 Long: `Report the version of linuxkit.
18 Run with option --short to print just the version number.
19 Run with option --commit to print just the git commit.`,
20 RunE: func(cmd *cobra.Command, args []string) error {
21 if short {
22 fmt.Println(version.Version)
23 return nil
24 }
25 if commit {
26 fmt.Println(version.GitCommit)
27 return nil
28 }
29 fmt.Printf("%s version %s\n", filepath.Base(os.Args[0]), version.Version)
30 if version.GitCommit != "" {
31 fmt.Printf("commit: %s\n", version.GitCommit)
32 }
33 return nil
34 },
35 }
36 cmd.Flags().BoolVar(&short, "short", false, "print just the version number")
37 cmd.Flags().BoolVar(&commit, "commit", false, "print just the commit")
38
39 return cmd
40}

Callers 1

newCmdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected