Files
2026-05-30 12:04:50 +02:00

55 lines
949 B
Go

/*
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
*/
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!")
}