Files
warewulf/internal/app/wwctl/container/rename/root.go
jason yang d262ec10ef Add container rename support
Signed-off-by: jason yang <jasonyangshadow@gmail.com>
2024-01-24 15:11:16 -07:00

36 lines
1.0 KiB
Go

package rename
import (
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/spf13/cobra"
)
var baseCmd = &cobra.Command{
DisableFlagsInUseLine: true,
Use: "rename CONTAINER NEW_NAME",
Aliases: []string{"rn"},
Short: "Rename an existing container",
Long: "This command will rename an existing container.",
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, _ := container.ListSources()
return list, cobra.ShellCompDirectiveNoFileComp
},
}
var SetBuild bool
func init() {
// Nothing to do here
baseCmd.PersistentFlags().BoolVarP(&SetBuild, "build", "b", false, "Build container after rename")
}
// GetRootCommand returns the root cobra.Command for the application.
func GetCommand() *cobra.Command {
return baseCmd
}