Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Commit

Permalink
use buildinfo in version cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
martinnirtl committed Feb 27, 2020
1 parent 79afd53 commit a10200b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions internal/commands/versioncmd/root.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
package versioncmd

import (
"fmt"

"github.com/martinnirtl/dockma/internal/buildinfo"
"github.com/spf13/cobra"
)

var fullFlag bool

// GetVersionCommand returns the top level version command
func GetVersionCommand() *cobra.Command {
return &cobra.Command{
versionCommand := &cobra.Command{
Use: "version",
Short: "Print the version number of dockma.",
Long: "Print the version number of dockma.",
Example: "dockma version",
Args: cobra.NoArgs,
Hidden: true,
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
Run: runVersionCommand,
}

versionCommand.Flags().BoolVarP(&fullFlag, "full", "f", false, "print full version description")

return versionCommand
}

func runVersionCommand(cmd *cobra.Command, args []string) {
// TODO use version from build flags
fmt.Println("🐳 Dockma v0.0.0")
if fullFlag {
buildinfo.Version.PrintFull()
} else {
buildinfo.Version.Print()
}
}

0 comments on commit a10200b

Please sign in to comment.