From 62586fc58a06c025419f912bf31532283b022104 Mon Sep 17 00:00:00 2001 From: defanor Date: Thu, 28 Mar 2019 07:24:17 +0300 Subject: Shorten commands --- DWProxy.hs | 21 ++++++++++----------- README.md | 6 +++--- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/DWProxy.hs b/DWProxy.hs index a8d4acd..5ff3cf7 100644 --- a/DWProxy.hs +++ b/DWProxy.hs @@ -275,19 +275,18 @@ data Config = Config { cClient :: Socket } pRouteChoice :: Parser Command -pRouteChoice = do - _ <- "route " - d <- decimal - _ <- "\r\n" - pure $ RouteChoice d +pRouteChoice = RouteChoice <$> decimal <* "\r\n" pSpeedWalk :: Parser Command -pSpeedWalk = do - _ <- "speedwalk " - from <- ("from " *> (Just <$> manyTill (notChar '\255') " to ")) - <|> ("to " *> pure Nothing) - to <- manyTill (notChar '\255') "\r\n" - pure $ SpeedWalk from to +pSpeedWalk = full <|> short + where + short = "sw " *> (SpeedWalk Nothing <$> manyTill (notChar '\255') "\r\n") + full = do + _ <- "speedwalk " + from <- ("from " *> (Just <$> manyTill (notChar '\255') " to ")) + <|> ("to " *> pure Nothing) + to <- manyTill (notChar '\255') "\r\n" + pure $ SpeedWalk from to pShopSearch :: Parser Command pShopSearch = ShopSearch <$> ("shop " *> manyTill (notChar '\255') "\r\n") diff --git a/README.md b/README.md index b4ace02..534feb8 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ This is a client-agnostic proxy for the Discworld MUD, which adds new commands: -- `speedwalk [from ] to `: find routes, walk if - there's only one -- `route `: select a speedwalk route option +- `speedwalk [from ] to ` or `sw `: + find routes, walk if there's only one +- ``: select a speedwalk route option - `shop `: search shops by items they sell It uses the database from [Quow's Cow Bar and -- cgit v1.2.3