summaryrefslogtreecommitdiff
path: root/Pancake/Command.hs
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2019-02-18 12:05:36 +0300
committerdefanor <defanor@uberspace.net>2019-02-18 12:05:36 +0300
commit637f52294ef1a7ee6bbaf3fa8eda8e35472d316e (patch)
treee6c21981cb328d4c1986b3eba9ad74cd42c9210c /Pancake/Command.hs
parente198647ea5e12c6d80b74b615d382de9beb5d6b6 (diff)
Add the "gs" command for Gopher search
Diffstat (limited to 'Pancake/Command.hs')
-rw-r--r--Pancake/Command.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/Pancake/Command.hs b/Pancake/Command.hs
index 4686924..297a438 100644
--- a/Pancake/Command.hs
+++ b/Pancake/Command.hs
@@ -52,6 +52,7 @@ data Command = Quit
| More
| GoTo (Maybe String) Reference
-- ^ Document type, reference
+ | GopherSearch Int String
| Save Reference (Maybe FilePath)
| Back
| Forward
@@ -166,6 +167,16 @@ loadConf = string "load config"
*> (LoadConfig <$> optionMaybe (space *> many1 anyChar))
<* eof
+gopherSearch :: String -> Parser Command
+gopherSearch digits = do
+ string "gs"
+ space
+ ref <- pNumber digits
+ _ <- space
+ query <- many1 anyChar
+ _ <- eof
+ pure $ GopherSearch ref query
+
-- | Command parser.
command :: Config -> Parser Command
command c =
@@ -181,4 +192,5 @@ command c =
, setPos <?> "set position"
, loadConf <?> "load config"
, goTo <?> "follow uri"
+ , gopherSearch (referenceDigits c) <?> "gopher search"
])