55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
/*
|
|
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
|
*/
|
|
package grant
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
"mbase/app/operator"
|
|
)
|
|
|
|
type Util struct {
|
|
oper *operator.Logic
|
|
rootCmd *cobra.Command
|
|
createGrantParams createGrantParams
|
|
deleteGrantParams deleteGrantParams
|
|
}
|
|
|
|
func NewUtil(oper *operator.Logic) *Util {
|
|
return &Util{
|
|
oper: oper,
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|