working commit
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
||||
*
|
||||
* This work is published and licensed under a Creative Commons
|
||||
* Attribution-NonCommercial-NoDerivatives 4.0 International License.
|
||||
*
|
||||
* Distribution of this work is permitted, but commercial use and
|
||||
* modifications are strictly prohibited.
|
||||
*/
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"helmet/cmd/minilbctl/forwarder"
|
||||
"helmet/cmd/minilbctl/service"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
type Tool struct {
|
||||
cmd *cobra.Command
|
||||
forwarderTool *forwarder.Tool
|
||||
serviceTool *service.Tool
|
||||
}
|
||||
|
||||
func NewTool() *Tool {
|
||||
execName := filepath.Base(os.Args[0])
|
||||
tool := &Tool{}
|
||||
tool.cmd = &cobra.Command{
|
||||
Use: execName,
|
||||
Short: "\nService tools",
|
||||
SilenceUsage: true,
|
||||
}
|
||||
tool.cmd.CompletionOptions.DisableDefaultCmd = true
|
||||
|
||||
tool.serviceTool = service.NewTool()
|
||||
tool.cmd.AddCommand(tool.serviceTool.GetCmd())
|
||||
|
||||
tool.forwarderTool = forwarder.NewTool()
|
||||
tool.cmd.AddCommand(tool.forwarderTool.GetCmd())
|
||||
return tool
|
||||
}
|
||||
|
||||
func (tool *Tool) Exec(args []string) error {
|
||||
tool.cmd.SetArgs(args)
|
||||
return tool.cmd.Execute()
|
||||
}
|
||||
Reference in New Issue
Block a user