wwctl image completions and arguments

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-02-08 14:52:48 -07:00
parent 1d34477425
commit 5494424c09
14 changed files with 59 additions and 55 deletions

View File

@@ -11,10 +11,6 @@ import (
)
func CobraRunE(cmd *cobra.Command, args []string) (err error) {
if len(args) != 2 {
return fmt.Errorf("rename requires 2 arguments: %d provided", len(args))
}
crp := &wwapiv1.ImageRenameParameter{
ImageName: args[0],
TargetName: args[1],

View File

@@ -2,7 +2,7 @@ package rename
import (
"github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/pkg/image"
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
)
var baseCmd = &cobra.Command{
@@ -12,14 +12,8 @@ var baseCmd = &cobra.Command{
Short: "Rename an existing image",
Long: "This command will rename an existing image.",
RunE: CobraRunE,
Args: cobra.MinimumNArgs(2),
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 {
return nil, cobra.ShellCompDirectiveNoFileComp
}
list, _ := image.ListSources()
return list, cobra.ShellCompDirectiveNoFileComp
},
Args: cobra.ExactArgs(2),
ValidArgsFunction: completions.Images(1),
}
var SetBuild bool