/* * Copyright 2026 Oleg Borodin */ package util import ( "fmt" "os" "path/filepath" "mproxy/cmd/mproxyctl/servcmd" "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: "\nSupport tools", SilenceUsage: true, } rootCmd.CompletionOptions.DisableDefaultCmd = true util.rootCmd = rootCmd ServiceUtil := servcmd.NewServiceUtil() rootCmd.AddCommand(ServiceUtil.MakeServiceCmds()) return err } func (util *Util) Exec(args []string) error { var err error util.rootCmd.SetArgs(args) err = util.rootCmd.Execute() return err } func (util *Util) Hello(cmd *cobra.Command, args []string) { fmt.Println("hello, world!") }