QBitRun/cmd/qbitrun/cli/handle.go
2024-06-25 00:19:15 +07:00

73 lines
2.3 KiB
Go

package cli
import "github.com/spf13/cobra"
type handleArgsS struct {
torrentName string
category string
tags []string
contentPath string
rootPath string
savePath string
numberOfFiles int
torrentSize uint64
currentTracker string
infoHashV1 string
infoHashV2 string
torrentID string
addEvent bool
}
var handleArgs = handleArgsS{}
var handleCmd = &cobra.Command{
Use: "handle",
Short: "Handles a torrent event from QBittorrent",
Run: func(cmd *cobra.Command, args []string) {
},
}
func init() {
flags := handleCmd.Flags()
flags.BoolVarP(&handleArgs.addEvent, "add-event", "a", false, "mark this event as add torrent event")
flags.StringVarP(&handleArgs.torrentName, "torrent-name", "N", "", "Torrent Name")
handleCmd.MarkFlagRequired("torrent-name")
flags.StringVarP(&handleArgs.category, "category", "L", "", "Category")
handleCmd.MarkFlagRequired("category")
flags.StringSliceVarP(&handleArgs.tags, "tags", "G", []string{}, "Tags (seperated by comma)")
handleCmd.MarkFlagRequired("tags")
flags.StringVarP(&handleArgs.contentPath, "content-path", "F", "", "Content Path (same as root path for multifile torrent")
handleCmd.MarkFlagRequired("content-path")
flags.StringVarP(&handleArgs.rootPath, "root-path", "R", "", "Root path (first torrent subdirectory path)")
handleCmd.MarkFlagRequired("root-path")
flags.StringVarP(&handleArgs.savePath, "save-path", "D", "", "Save path")
handleCmd.MarkFlagRequired("save-path")
flags.IntVarP(&handleArgs.numberOfFiles, "number-of-files", "C", 0, "Number of files")
handleCmd.MarkFlagRequired("number-of-files")
flags.Uint64VarP(&handleArgs.torrentSize, "torrent-size", "Z", 0, "Torrent size")
handleCmd.MarkFlagRequired("torrent-size")
flags.StringVarP(&handleArgs.currentTracker, "current-tracker", "T", "", "Current tracker")
handleCmd.MarkFlagRequired("current-tracker")
flags.StringVarP(&handleArgs.infoHashV1, "info-hash-v1", "I", "", "Info hash v1")
handleCmd.MarkFlagRequired("info-hash-v1")
flags.StringVarP(&handleArgs.infoHashV2, "info-hash-v2", "J", "", "Info hash v2")
handleCmd.MarkFlagRequired("info-hash-v2")
flags.StringVarP(&handleArgs.torrentID, "torrent-id", "K", "", "Torrent ID")
handleCmd.MarkFlagRequired("torrent-id")
RootCmd.AddCommand(handleCmd)
}