This repository has been archived by the owner on Jun 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79afd53
commit a10200b
Showing
1 changed file
with
13 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |