Skip to content

Commit

Permalink
feat(cmd): add forward
Browse files Browse the repository at this point in the history
  • Loading branch information
iyear committed Nov 16, 2023
1 parent b0ac970 commit ae6cdab
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions cmd/forward.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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")

return cmd
}
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func New() *cobra.Command {
},
}

cmd.AddCommand(NewVersion(), NewLogin(), NewDownload(),
cmd.AddCommand(NewVersion(), NewLogin(), NewDownload(), NewForward(),
NewChat(), NewUpload(), NewBackup(), NewRecover(), NewGen())

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

0 comments on commit ae6cdab

Please sign in to comment.