Added some Cobra framework for new command groups as I'm thinking through the interface.

This commit is contained in:
Gregory Kurtzer
2020-11-13 21:29:22 -08:00
parent 77bac0c8a8
commit c39257a7ff
5 changed files with 96 additions and 7 deletions

View File

@@ -0,0 +1,32 @@
package list
import (
"fmt"
"github.com/spf13/cobra"
)
var (
listCmd = &cobra.Command{
Use: "list",
Short: "List Warewulf Overlays",
Long: "Warewulf List overlay",
RunE: CobraRunE,
}
)
func init() {
}
// GetRootCommand returns the root cobra.Command for the application.
func GetCommand() *cobra.Command {
return listCmd
}
func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Printf("List: Hello World\n")
return nil
}

View File

@@ -0,0 +1,30 @@
package overlay
import (
"github.com/hpcng/warewulf/internal/app/wwctl/overlay/list"
"github.com/hpcng/warewulf/internal/app/wwctl/overlay/show"
"github.com/spf13/cobra"
)
var (
overlayCmd = &cobra.Command{
Use: "overlay",
Short: "Warewulf Overlay Management",
Long: "Management interface for Warewulf overlays",
}
test bool
)
func init() {
overlayCmd.PersistentFlags().BoolVarP(&test, "test", "t", false, "Testing.")
overlayCmd.AddCommand(list.GetCommand())
overlayCmd.AddCommand(show.GetCommand())
}
// GetRootCommand returns the root cobra.Command for the application.
func GetCommand() *cobra.Command {
return overlayCmd
}

View File

@@ -0,0 +1,32 @@
package show
import (
"fmt"
"github.com/spf13/cobra"
)
var (
showCmd = &cobra.Command{
Use: "show",
Short: "Show Warewulf Overlay objects",
Long: "Warewulf show overlay objects",
RunE: CobraRunE,
}
)
func init() {
}
// GetRootCommand returns the root cobra.Command for the application.
func GetCommand() *cobra.Command {
return showCmd
}
func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Printf("Show: Hello World\n")
return nil
}

View File

@@ -2,6 +2,7 @@ package wwctl
import (
"github.com/hpcng/warewulf/internal/app/wwctl/build"
"github.com/hpcng/warewulf/internal/app/wwctl/overlay"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra"
)
@@ -22,6 +23,7 @@ func init() {
rootCmd.PersistentFlags().BoolVarP(&debugArg, "debug", "d", false, "Run with debugging messages enabled.")
rootCmd.AddCommand(build.GetCommand())
rootCmd.AddCommand(overlay.GetCommand())
}
// GetRootCommand returns the root cobra.Command for the application.