Files
gmbase/cmd/mbasectl/util.go
T
2026-06-08 09:42:32 +02:00

50 lines
838 B
Go

/*
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
*/
package main
import (
"os"
"path/filepath"
"mbase/cmd/mbasectl/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
}