tdl/cmd/forward.go

33 lines
1.0 KiB
Go
Raw Normal View History

2023-11-16 23:04:07 +08:00
package cmd
import (
"fmt"
"strings"
"github.com/spf13/cobra"
"github.com/iyear/tdl/app/forward"
"github.com/iyear/tdl/pkg/forwarder"
"github.com/iyear/tdl/pkg/logger"
)
func NewForward() *cobra.Command {
var opts forward.Options
cmd := &cobra.Command{
Use: "forward",
Short: "Forward messages with automatic fallback and message routing",
RunE: func(cmd *cobra.Command, args []string) error {
return forward.Run(logger.Named(cmd.Context(), "forward"), opts)
},
}
cmd.Flags().StringArrayVar(&opts.From, "from", []string{}, "messages to be forwarded, can be links or exported JSON files")
cmd.Flags().StringVar(&opts.To, "to", "", "destination peer, can be a CHAT or router based on expression engine")
cmd.Flags().Var(&opts.Mode, "mode", fmt.Sprintf("forward mode: [%s]", strings.Join(forwarder.ModeNames(), ", ")))
cmd.Flags().BoolVar(&opts.Silent, "silent", false, "send messages silently")
2023-11-17 00:27:30 +08:00
cmd.Flags().BoolVar(&opts.DryRun, "dry-run", false, "do not actually send messages, just show how they would be sent")
2023-11-16 23:04:07 +08:00
return cmd
}