working commit
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
||||
*/
|
||||
package grant
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
type Util struct {
|
||||
rootCmd *cobra.Command
|
||||
createGrantParams createGrantParams
|
||||
deleteGrantParams deleteGrantParams
|
||||
}
|
||||
|
||||
func NewUtil() *Util {
|
||||
return &Util{}
|
||||
}
|
||||
|
||||
func (util *Util) GetRooCmd() *cobra.Command {
|
||||
return util.rootCmd
|
||||
}
|
||||
|
||||
func (util *Util) BuildCmds() *cobra.Command {
|
||||
rootCmd := &cobra.Command{
|
||||
Use: "grant",
|
||||
Short: "\nGrant operations",
|
||||
SilenceUsage: true,
|
||||
}
|
||||
rootCmd.CompletionOptions.DisableDefaultCmd = true
|
||||
|
||||
var createGrantCmd = &cobra.Command{
|
||||
Use: "create name|id password",
|
||||
Short: "Create grant",
|
||||
Args: cobra.ExactArgs(2),
|
||||
Run: util.CreateGrant,
|
||||
}
|
||||
rootCmd.AddCommand(createGrantCmd)
|
||||
|
||||
var deleteGrantCmd = &cobra.Command{
|
||||
Use: "delete name|id grant",
|
||||
Short: "Delete grant",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: util.DeleteGrant,
|
||||
}
|
||||
rootCmd.AddCommand(deleteGrantCmd)
|
||||
|
||||
util.rootCmd = rootCmd
|
||||
return util.rootCmd
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user