39 lines
854 B
Go
39 lines
854 B
Go
package subcommands
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
|
|
"github.com/bedrock-tool/bedrocktool/locale"
|
|
"github.com/bedrock-tool/bedrocktool/utils"
|
|
)
|
|
|
|
func init() {
|
|
utils.RegisterCommand(&CaptureCMD{})
|
|
}
|
|
|
|
type CaptureCMD struct {
|
|
ServerAddress string
|
|
}
|
|
|
|
func (*CaptureCMD) Name() string { return "capture" }
|
|
func (*CaptureCMD) Synopsis() string { return locale.Loc("capture_synopsis", nil) }
|
|
func (c *CaptureCMD) SetFlags(f *flag.FlagSet) {
|
|
f.StringVar(&c.ServerAddress, "address", "", "remote server address")
|
|
}
|
|
|
|
func (c *CaptureCMD) Execute(ctx context.Context, ui utils.UI) error {
|
|
address, hostname, err := utils.ServerInput(ctx, c.ServerAddress)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
proxy, err := utils.NewProxy()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
proxy.AlwaysGetPacks = true
|
|
utils.Options.Capture = true
|
|
return proxy.Run(ctx, address, hostname)
|
|
}
|