50 lines
840 B
Go
50 lines
840 B
Go
/*
|
|
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
|
*/
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"mbase/cmd/mbaseadmin/account"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
type Util struct {
|
|
rootCmd *cobra.Command
|
|
}
|
|
|
|
func NewUtil() *Util {
|
|
return &Util{}
|
|
}
|
|
|
|
func (util *Util) GetRooCmd() *cobra.Command {
|
|
return util.rootCmd
|
|
}
|
|
|
|
func (util *Util) Build() error {
|
|
var err error
|
|
execName := filepath.Base(os.Args[0])
|
|
rootCmd := &cobra.Command{
|
|
Use: execName,
|
|
Short: "\nAccount operations",
|
|
SilenceUsage: true,
|
|
}
|
|
rootCmd.CompletionOptions.DisableDefaultCmd = true
|
|
|
|
accountUtil := account.NewUtil()
|
|
rootCmd.AddCommand(accountUtil.BuildCmds())
|
|
|
|
util.rootCmd = rootCmd
|
|
return err
|
|
}
|
|
|
|
func (util *Util) Exec(args []string) error {
|
|
var err error
|
|
util.rootCmd.SetArgs(args)
|
|
err = util.rootCmd.Execute()
|
|
return err
|
|
}
|