From 7c51ac500bf453cfdcd25c40ba7690a753b94f38 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Sun, 19 Jul 2015 14:28:32 +0530
Subject: [PATCH] src/Main.hs: if no input file is given, read from stdin

This change makes it play nicely as a Unix program that consumes
streams of bytes. One possible usage is to do a 'curl' of the torrent
file and pipe into the functorrent program.
---
 src/Main.hs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/Main.hs b/src/Main.hs
index 12af02e..867e962 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -1,8 +1,8 @@
 {-# LANGUAGE OverloadedStrings #-}
 module Main where
 
-import Prelude hiding (log, length, readFile)
-import Data.ByteString.Char8 (ByteString, readFile, unpack)
+import Prelude hiding (log, length, readFile, getContents)
+import Data.ByteString.Char8 (ByteString, getContents, readFile, unpack)
 import System.Environment (getArgs)
 import System.Exit (exitSuccess)
 import System.Directory (doesFileExist)
@@ -25,7 +25,7 @@ usage :: IO ()
 usage = putStrLn "usage: functorrent torrent-file"
 
 parse :: [String] -> IO ByteString
-parse [] = usage >> exit
+parse [] = getContents
 parse [a] = do
   fileExist <- doesFileExist a
   if fileExist
-- 
2.45.2