Merge pull request #165 from mslacken/version

Version
This commit is contained in:
Christian Goll
2021-12-08 21:27:34 +01:00
committed by GitHub
6 changed files with 55 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ import (
"github.com/hpcng/warewulf/internal/app/wwctl/power"
"github.com/hpcng/warewulf/internal/app/wwctl/profile"
"github.com/hpcng/warewulf/internal/app/wwctl/server"
"github.com/hpcng/warewulf/internal/app/wwctl/version"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/hpcng/warewulf/internal/pkg/help"
"github.com/spf13/cobra"
@@ -46,6 +47,7 @@ func init() {
rootCmd.AddCommand(profile.GetCommand())
rootCmd.AddCommand(configure.GetCommand())
rootCmd.AddCommand(server.GetCommand())
rootCmd.AddCommand(version.GetCommand())
}

View File

@@ -0,0 +1,15 @@
package version
import (
"fmt"
"github.com/hpcng/warewulf/internal/pkg/version"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Println("Version:\t", version.GetVersion())
return nil
}

View File

@@ -0,0 +1,22 @@
package version
import "github.com/spf13/cobra"
var (
baseCmd = &cobra.Command{
Use: "version",
Short: "Version information",
Long: "This command will print the Warewulf version.",
RunE: CobraRunE,
Args: cobra.ExactArgs(0),
Aliases: []string{"vers"},
}
)
func init() {
}
// GetRootCommand returns the root cobra.Command for the application.
func GetCommand() *cobra.Command {
return baseCmd
}