refactor to overlay info
This commit is contained in:
committed by
Jonathon Anderson
parent
d1d398d2ff
commit
983a359c00
38
internal/app/wwctl/overlay/info/root.go
Normal file
38
internal/app/wwctl/overlay/info/root.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package info
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/warewulf/warewulf/internal/pkg/overlay"
|
||||
)
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "info [flags] OVERLAY_NAME FILE_PATH",
|
||||
Short: "Show variables for a template file in an overlay",
|
||||
Long: "This command will show the variables for a given template file in a given\n" + "overlay.",
|
||||
Aliases: []string{"vars", "tags", "information"},
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: CobraRunE,
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) == 0 {
|
||||
return overlay.FindOverlays(), cobra.ShellCompDirectiveNoFileComp
|
||||
} else if len(args) == 1 {
|
||||
ov, err := overlay.Get(args[0])
|
||||
if err != nil {
|
||||
return nil, cobra.ShellCompDirectiveError
|
||||
}
|
||||
files, err := ov.GetFiles()
|
||||
if err != nil {
|
||||
return nil, cobra.ShellCompDirectiveError
|
||||
}
|
||||
return files, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// GetCommand returns the root cobra.Command for this application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
Reference in New Issue
Block a user