Skip to content

Commit ae6cdab

Browse files
committed
feat(cmd): add forward
1 parent b0ac970 commit ae6cdab

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

cmd/forward.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
7+
"github.com/spf13/cobra"
8+
9+
"github.com/iyear/tdl/app/forward"
10+
"github.com/iyear/tdl/pkg/forwarder"
11+
"github.com/iyear/tdl/pkg/logger"
12+
)
13+
14+
func NewForward() *cobra.Command {
15+
var opts forward.Options
16+
17+
cmd := &cobra.Command{
18+
Use: "forward",
19+
Short: "Forward messages with automatic fallback and message routing",
20+
RunE: func(cmd *cobra.Command, args []string) error {
21+
return forward.Run(logger.Named(cmd.Context(), "forward"), opts)
22+
},
23+
}
24+
25+
cmd.Flags().StringArrayVar(&opts.From, "from", []string{}, "messages to be forwarded, can be links or exported JSON files")
26+
cmd.Flags().StringVar(&opts.To, "to", "", "destination peer, can be a CHAT or router based on expression engine")
27+
cmd.Flags().Var(&opts.Mode, "mode", fmt.Sprintf("forward mode: [%s]", strings.Join(forwarder.ModeNames(), ", ")))
28+
cmd.Flags().BoolVar(&opts.Silent, "silent", false, "send messages silently")
29+
30+
return cmd
31+
}

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func New() *cobra.Command {
4040
},
4141
}
4242

43-
cmd.AddCommand(NewVersion(), NewLogin(), NewDownload(),
43+
cmd.AddCommand(NewVersion(), NewLogin(), NewDownload(), NewForward(),
4444
NewChat(), NewUpload(), NewBackup(), NewRecover(), NewGen())
4545

4646
cmd.PersistentFlags().String(consts.FlagProxy, "", "proxy address, only socks5 is supported, format: protocol://username:password@host:port")

0 commit comments

Comments
 (0)