blob: a9d2a44fac6e8d7a02a609dd31c6257243fbfd42 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
module Main (main) where
import Data.Default
import Options.Applicative
import Data.Torrent.InfoHash
import Network.BitTorrent.Core
data Params = Params
{ infohash :: InfoHash
, thisNode :: NodeAddr IPv4
, bootNode :: NodeAddr IPv4
} deriving Show
paramsParser :: Parser Params
paramsParser = Params
<$> option (long "infohash" <> short 'i'
<> metavar "SHA1" <> help "infohash of torrent file")
<*> option (long "node" <> short 'n' <> value def
<> metavar "NODE" <> help "this node address"
)
<*> option (long "boot" <> short 'b'
<> metavar "NODE" <> help "bootstrap node address"
)
programInfo :: ParserInfo Params
programInfo = info (helper <*> paramsParser)
( fullDesc
<> progDesc ""
<> header "gettorrent - get torrent file by infohash"
)
getTorrent :: Params -> IO ()
getTorrent = print
main :: IO ()
main = execParser programInfo >>= getTorrent
|