Files
warewulf/internal/app/wwctl/overlay/info/root.go
Jonathon Anderson 29136e17d4 Recommended changes from review
- Reorganized documentation
- Reordered columns
- Renamed column names
- Added `--` to options in output
- Updated aliases

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2025-12-09 22:52:44 -07:00

39 lines
1.1 KiB
Go

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{"variables", "vars"},
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
}