summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-08-22 20:41:02 -0400
committerjoe <joe@jerkface.net>2017-08-22 20:41:02 -0400
commit546c0e95768757c1b540807d22b232bc3397f7c7 (patch)
treed7a126850caecf74433a0cc12c0519cf4ebf4105 /examples
parentcf6007bcd3c64a83b9892d45ba1908ef729890ab (diff)
dht client: Send multiple commands on commandline.
Diffstat (limited to 'examples')
-rw-r--r--examples/dht.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/examples/dht.hs b/examples/dht.hs
index 534a319b..3e1b1656 100644
--- a/examples/dht.hs
+++ b/examples/dht.hs
@@ -4,6 +4,7 @@ import Control.Monad
4import Data.Function 4import Data.Function
5import Control.Monad.IO.Class 5import Control.Monad.IO.Class
6import Data.Char 6import Data.Char
7import Data.List
7import Network.Socket as Socket 8import Network.Socket as Socket
8import System.Console.Haskeline 9import System.Console.Haskeline
9import System.Environment 10import System.Environment
@@ -82,5 +83,8 @@ main = do
82 -- or else we enter an interactive shell. 83 -- or else we enter an interactive shell.
83 args <- dropWhile isSpace . unwords <$> liftIO getArgs 84 args <- dropWhile isSpace . unwords <$> liftIO getArgs
84 case args of 85 case args of
85 (_:_) -> sendCommand h args >> sendCommand h "quit" 86 (_:_) -> do
87 let cs = filter (not . null) $ map (drop 1) $ groupBy (\_ c -> (c/=';')) (';':args)
88 forM_ cs $ \cmd -> sendCommand h cmd
89 sendCommand h "quit"
86 _ -> fix $ interactiveMode h 90 _ -> fix $ interactiveMode h