From 546c0e95768757c1b540807d22b232bc3397f7c7 Mon Sep 17 00:00:00 2001 From: joe Date: Tue, 22 Aug 2017 20:41:02 -0400 Subject: dht client: Send multiple commands on commandline. --- examples/dht.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'examples') 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 import Data.Function import Control.Monad.IO.Class import Data.Char +import Data.List import Network.Socket as Socket import System.Console.Haskeline import System.Environment @@ -82,5 +83,8 @@ main = do -- or else we enter an interactive shell. args <- dropWhile isSpace . unwords <$> liftIO getArgs case args of - (_:_) -> sendCommand h args >> sendCommand h "quit" + (_:_) -> do + let cs = filter (not . null) $ map (drop 1) $ groupBy (\_ c -> (c/=';')) (';':args) + forM_ cs $ \cmd -> sendCommand h cmd + sendCommand h "quit" _ -> fix $ interactiveMode h -- cgit v1.2.3