working commit

This commit is contained in:
2026-06-09 14:10:53 +02:00
parent ee30858d11
commit 6e92720e69
26 changed files with 339 additions and 165 deletions
+26 -7
View File
@@ -4,13 +4,24 @@
package grant
import (
"mbase/pkg/client"
"github.com/spf13/cobra"
)
type CommonParams struct {
Hostname string
Port uint32
Username string
Password string
}
type Util struct {
rootCmd *cobra.Command
createGrantParams createGrantParams
rootCmd *cobra.Command
setGrantParams SetGrantParams
deleteGrantParams deleteGrantParams
commonParams CommonParams
access client.Access
}
func NewUtil() *Util {
@@ -29,13 +40,13 @@ func (util *Util) BuildCmds() *cobra.Command {
}
rootCmd.CompletionOptions.DisableDefaultCmd = true
var createGrantCmd = &cobra.Command{
Use: "create name|id password",
Short: "Create grant",
var setGrantCmd = &cobra.Command{
Use: "set name|id grant",
Short: "Set grant",
Args: cobra.ExactArgs(2),
Run: util.CreateGrant,
Run: util.SetGrant,
}
rootCmd.AddCommand(createGrantCmd)
rootCmd.AddCommand(setGrantCmd)
var deleteGrantCmd = &cobra.Command{
Use: "delete name|id grant",
@@ -49,3 +60,11 @@ func (util *Util) BuildCmds() *cobra.Command {
return util.rootCmd
}
func (util *Util) SetAccess(cmd *cobra.Command, args []string) {
util.access = client.Access{
Hostname: util.commonParams.Hostname,
Port: util.commonParams.Port,
Username: util.commonParams.Username,
Password: util.commonParams.Password,
}
}