Documentation
¶
Overview ¶
Utilities funcs that have side effects.
Index ¶
- Variables
- func AskYesNoConfirm(prompt string) bool
- func GetTemplate(tpl string) (*template.Template, error)
- func GetTorrentContent(torrent string, defaultSite string, forceLocal bool, forceRemote bool, ...) (content []byte, tinfo *torrentutil.TorrentMeta, siteInstance site.Site, ...)
- func GetWildcardFilenames(filestr string) []string
- func ParseFilenameArgs(args ...string) []string
- func ParseInfoHashesFromArgs(args []string) (infoHashes []string, err error)
- func ParseTorrentsFromArgs(args []string) (torrents []string, stdinTorrentContents []byte, err error)
- func ReadArgsFromStdin() ([]string, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func AskYesNoConfirm ¶ added in v0.1.10
Ask user to confirm an (dangerous) action via typing yes in tty
func GetTemplate ¶ added in v0.1.10
Get a Go text template instance from tpl string. If tpl starts with "@" char, treat it (the rest part after @) as a file name and read template contents from it instead.
func GetTorrentContent ¶
func GetTorrentContent(torrent string, defaultSite string, forceLocal bool, forceRemote bool, stdin []byte, ignoreParsingError bool, beforeDownload func(sitename string, id string) error) ( content []byte, tinfo *torrentutil.TorrentMeta, siteInstance site.Site, sitename string, filename string, id string, isLocal bool, err error)
Read a torrent and return it's contents. torrent could be: local filename (e.g. abc.torrent), site torrent id (e.g. mteam.1234) or url (e.g. https://kp.m-team.cc/details.php?id=488424), or "-" to read torrent contents from os.Stdin. Params: forceLocal: force treat torrent as local filename. forceRemote: force treat torrent as site torrent id or url. ignoreParsingError: ignore torrent parsing error, in which case the returned tinfo may by nil. stdin: if not nil, use it as torrent contents when torrent == "-" instead of reading from os.Stdin. beforeDownload: a optional func that be called before downloading each torrent from remote, if the func return a non-nil error, will NOT do download and instead return that err. Return: siteInstance : if torrent is a site torrent, the created corresponding site instance. sitename & filename & id : if torrent is a site torrent, the downloaded torrent sitename & filename & id. isLocal: whether torrent is a local or remote torrent.
func GetWildcardFilenames ¶ added in v0.1.10
"*.torrent" => ["./a.torrent", "./b.torrent"...]. Return nil if filestr does not contains wildcard char. Windows cmd / powershell 均不支持命令行 *.torrent 参数扩展。必须应用自己实现。做个简易版的.
func ParseFilenameArgs ¶ added in v0.1.10
func ParseInfoHashesFromArgs ¶ added in v0.1.10
Parse info-hash list from args. If args is a single "-", read the list from stdin instead. It returns an error if parsed info-hash list is empty.
func ParseTorrentsFromArgs ¶ added in v0.1.10
func ParseTorrentsFromArgs(args []string) (torrents []string, stdinTorrentContents []byte, err error)
Parse torrent list from args. If args is a single "-", read the list from stdin instead, unless stdin contents is a valid .torrent file, in which case returned torrents is ["-"] and stdin contents returned as stdinTorrentContents. It returns an error if parsed torrents list is empty.
func ReadArgsFromStdin ¶
Read whitespace splitted tokens from stdin
Types ¶
This section is empty.