wwctl completions for no args

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-02-09 15:28:30 -07:00
parent 760b6e5217
commit 65f85a00a3
11 changed files with 67 additions and 35 deletions

View File

@@ -2,6 +2,7 @@ package clean
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
) )
type variables struct { type variables struct {
@@ -15,7 +16,8 @@ func GetCommand() *cobra.Command {
Short: "Clean up", Short: "Clean up",
Long: "This command cleans the OCI cache and removes leftovers from deleted nodes", Long: "This command cleans the OCI cache and removes leftovers from deleted nodes",
RunE: CobraRunE(&vars), RunE: CobraRunE(&vars),
Args: cobra.ExactArgs(0), Args: cobra.NoArgs,
ValidArgsFunction: completions.None,
} }
return baseCmd return baseCmd
} }

View File

@@ -2,6 +2,7 @@ package dhcp
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
) )
var ( var (
@@ -11,8 +12,9 @@ var (
Short: "Manage and initialize DHCP", Short: "Manage and initialize DHCP",
Long: "DHCP is a dependent service to Warewulf. This command will configure DHCP as defined\n" + Long: "DHCP is a dependent service to Warewulf. This command will configure DHCP as defined\n" +
"in the warewulf.conf file.", "in the warewulf.conf file.",
RunE: CobraRunE, RunE: CobraRunE,
Args: cobra.ExactArgs(0), Args: cobra.NoArgs,
ValidArgsFunction: completions.None,
} }
) )

View File

@@ -1,6 +1,9 @@
package hostfile package hostfile
import "github.com/spf13/cobra" import (
"github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
)
var ( var (
baseCmd = &cobra.Command{ baseCmd = &cobra.Command{
@@ -9,7 +12,8 @@ var (
Short: "update hostfile on master", Short: "update hostfile on master",
Long: "Manage the hostfile on the master node\n", Long: "Manage the hostfile on the master node\n",
RunE: CobraRunE, RunE: CobraRunE,
Args: cobra.ExactArgs(0), Args: cobra.NoArgs,
ValidArgsFunction: completions.None,
} }
) )

View File

@@ -1,6 +1,9 @@
package nfs package nfs
import "github.com/spf13/cobra" import (
"github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
)
var ( var (
baseCmd = &cobra.Command{ baseCmd = &cobra.Command{
@@ -9,8 +12,9 @@ var (
Short: "Manage and initialize NFS", Short: "Manage and initialize NFS",
Long: "NFS is an optional dependent service of Warewulf, this tool will automatically\n" + Long: "NFS is an optional dependent service of Warewulf, this tool will automatically\n" +
"configure NFS as per the configuration in the warewulf.conf file.", "configure NFS as per the configuration in the warewulf.conf file.",
RunE: CobraRunE, RunE: CobraRunE,
Args: cobra.ExactArgs(0), Args: cobra.NoArgs,
ValidArgsFunction: completions.None,
} }
) )

View File

@@ -2,6 +2,7 @@ package ssh
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
) )
var ( var (
@@ -12,8 +13,9 @@ var (
Long: "SSH is an optionally dependent service for Warewulf, this tool will automatically\n" + Long: "SSH is an optionally dependent service for Warewulf, this tool will automatically\n" +
"setup the ssh keys nodes using the 'default' system overlay as well as user owned\n" + "setup the ssh keys nodes using the 'default' system overlay as well as user owned\n" +
"keys.", "keys.",
RunE: CobraRunE, RunE: CobraRunE,
Args: cobra.ExactArgs(0), Args: cobra.NoArgs,
ValidArgsFunction: completions.None,
} }
keyTypes []string keyTypes []string
) )

View File

@@ -1,6 +1,9 @@
package tftp package tftp
import "github.com/spf13/cobra" import (
"github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
)
var ( var (
baseCmd = &cobra.Command{ baseCmd = &cobra.Command{
@@ -9,8 +12,9 @@ var (
Short: "Manage and initialize TFTP", Short: "Manage and initialize TFTP",
Long: "TFTP is a dependent service of Warewulf, this tool will enable the tftp services\n" + Long: "TFTP is a dependent service of Warewulf, this tool will enable the tftp services\n" +
"on your Warewulf master.", "on your Warewulf master.",
RunE: CobraRunE, RunE: CobraRunE,
Args: cobra.ExactArgs(0), Args: cobra.NoArgs,
ValidArgsFunction: completions.None,
} }
setShow bool setShow bool
) )

View File

@@ -6,15 +6,18 @@ import (
"github.com/warewulf/warewulf/internal/app/wwctl/genconf/man" "github.com/warewulf/warewulf/internal/app/wwctl/genconf/man"
"github.com/warewulf/warewulf/internal/app/wwctl/genconf/reference" "github.com/warewulf/warewulf/internal/app/wwctl/genconf/reference"
"github.com/warewulf/warewulf/internal/app/wwctl/genconf/warewulfconf" "github.com/warewulf/warewulf/internal/app/wwctl/genconf/warewulfconf"
cobraCompletions "github.com/warewulf/warewulf/internal/app/wwctl/completions"
) )
var ( var (
baseCmd = &cobra.Command{ baseCmd = &cobra.Command{
Use: "genconfig", Use: "genconfig",
Short: "Generate various configurations", Short: "Generate various configurations",
Long: "This command will allow you to generate different configurations like bash-completions.", Long: "This command will allow you to generate different configurations like bash-completions.",
Args: cobra.ExactArgs(0), Args: cobra.NoArgs,
Aliases: []string{"cnf"}, Aliases: []string{"cnf"},
ValidArgsFunction: cobraCompletions.None,
} }
ListFull bool ListFull bool
WWctlRoot *cobra.Command WWctlRoot *cobra.Command

View File

@@ -2,15 +2,17 @@ package print
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
) )
var ( var (
baseCmd = &cobra.Command{ baseCmd = &cobra.Command{
Use: "print", Use: "print",
Short: "print wareweulf.conf", Short: "print wareweulf.conf",
Long: "This command prints the actual used warewulf.conf, can be used to create an empty valid warewulf.conf", Long: "This command prints the actual used warewulf.conf, can be used to create an empty valid warewulf.conf",
RunE: CobraRunE, RunE: CobraRunE,
Args: cobra.ExactArgs(0), Args: cobra.NoArgs,
ValidArgsFunction: completions.None,
} }
) )

View File

@@ -2,16 +2,18 @@ package warewulfconf
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
"github.com/warewulf/warewulf/internal/app/wwctl/genconf/warewulfconf/print" "github.com/warewulf/warewulf/internal/app/wwctl/genconf/warewulfconf/print"
) )
var ( var (
baseCmd = &cobra.Command{ baseCmd = &cobra.Command{
Use: "warewulfconf", Use: "warewulfconf",
Short: "access warewulf.conf", Short: "access warewulf.conf",
Long: "Commands for accessing the actual used warewulf.conf", Long: "Commands for accessing the actual used warewulf.conf",
Args: cobra.ExactArgs(0), Args: cobra.NoArgs,
Aliases: []string{"cnf"}, Aliases: []string{"cnf"},
ValidArgsFunction: completions.None,
} }
ListFull bool ListFull bool
WWctlRoot *cobra.Command WWctlRoot *cobra.Command

View File

@@ -5,6 +5,7 @@ import (
"syscall" "syscall"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
"github.com/warewulf/warewulf/internal/pkg/warewulfd" "github.com/warewulf/warewulf/internal/pkg/warewulfd"
) )
@@ -14,6 +15,8 @@ var (
Use: "server [OPTIONS]", Use: "server [OPTIONS]",
Short: "Start Warewulf server", Short: "Start Warewulf server",
RunE: CobraRunE, RunE: CobraRunE,
Args: cobra.NoArgs,
ValidArgsFunction: completions.None,
} }
) )

View File

@@ -1,15 +1,19 @@
package version package version
import "github.com/spf13/cobra" import (
"github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
)
var ( var (
baseCmd = &cobra.Command{ baseCmd = &cobra.Command{
Use: "version", Use: "version",
Short: "Version information", Short: "Version information",
Long: "This command will print the Warewulf version.", Long: "This command will print the Warewulf version.",
RunE: CobraRunE, RunE: CobraRunE,
Args: cobra.ExactArgs(0), Args: cobra.NoArgs,
Aliases: []string{"vers"}, Aliases: []string{"vers"},
ValidArgsFunction: completions.None,
} }
ListFull bool ListFull bool
) )