diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Client.hs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/examples/Client.hs b/examples/Client.hs index 8d676145..2fc66101 100644 --- a/examples/Client.hs +++ b/examples/Client.hs | |||
@@ -1,17 +1,22 @@ | |||
1 | module Main (main) where | 1 | module Main (main) where |
2 | |||
3 | import Control.Concurrent | ||
4 | import Data.Default | ||
5 | import System.Environment | 2 | import System.Environment |
6 | import Text.PrettyPrint.Class | 3 | import System.Exit |
7 | 4 | import System.IO | |
8 | import Network.BitTorrent | 5 | import Network.BitTorrent |
9 | 6 | ||
7 | parseArgs :: IO FilePath | ||
8 | parseArgs = do | ||
9 | args <- getArgs | ||
10 | case args of | ||
11 | [path] -> return path | ||
12 | _ -> do | ||
13 | hPutStrLn stderr "Usage: client file.torrent" | ||
14 | exitFailure | ||
10 | 15 | ||
11 | main :: IO () | 16 | main :: IO () |
12 | main = do | 17 | main = do |
13 | [path] <- getArgs | 18 | path <- parseArgs |
14 | torrent <- fromFile path | 19 | torrent <- fromFile path |
15 | let logger = \ _ _ _ _ -> return () | 20 | simpleClient $ do |
16 | withClient def logger $ flip runBitTorrent $ do | 21 | h <- openTorrent torrent |
17 | return () | 22 | return () |