summaryrefslogtreecommitdiff
path: root/examples/GetTorrent.hs
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-01-03 00:59:48 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-01-03 00:59:48 +0400
commit65107192f9c5f8ff134362a7b9d37cb3f73dad7e (patch)
treec04f56cf4ec079a47f9bdb5d9cc73cbcfa2ca6d3 /examples/GetTorrent.hs
parent8815a137d8300d62a897154ec4fd02917d22bcb3 (diff)
Add skeleton for gettorrent example
Diffstat (limited to 'examples/GetTorrent.hs')
-rw-r--r--examples/GetTorrent.hs37
1 files changed, 37 insertions, 0 deletions
diff --git a/examples/GetTorrent.hs b/examples/GetTorrent.hs
new file mode 100644
index 00000000..a9d2a44f
--- /dev/null
+++ b/examples/GetTorrent.hs
@@ -0,0 +1,37 @@
1module Main (main) where
2import Data.Default
3
4import Options.Applicative
5import Data.Torrent.InfoHash
6import Network.BitTorrent.Core
7
8
9data Params = Params
10 { infohash :: InfoHash
11 , thisNode :: NodeAddr IPv4
12 , bootNode :: NodeAddr IPv4
13 } deriving Show
14
15paramsParser :: Parser Params
16paramsParser = Params
17 <$> option (long "infohash" <> short 'i'
18 <> metavar "SHA1" <> help "infohash of torrent file")
19 <*> option (long "node" <> short 'n' <> value def
20 <> metavar "NODE" <> help "this node address"
21 )
22 <*> option (long "boot" <> short 'b'
23 <> metavar "NODE" <> help "bootstrap node address"
24 )
25
26programInfo :: ParserInfo Params
27programInfo = info (helper <*> paramsParser)
28 ( fullDesc
29 <> progDesc ""
30 <> header "gettorrent - get torrent file by infohash"
31 )
32
33getTorrent :: Params -> IO ()
34getTorrent = print
35
36main :: IO ()
37main = execParser programInfo >>= getTorrent