Query with regexes
This commit is contained in:
15
app/Main.hs
15
app/Main.hs
@ -1,3 +1,4 @@
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
module Main where
|
||||
|
||||
import Options.Applicative
|
||||
@ -10,17 +11,27 @@ import Data.Environment
|
||||
import UnliftIO.Directory
|
||||
(XdgDirectory(XdgData), getXdgDirectory)
|
||||
|
||||
import Data.Foldable
|
||||
(asum)
|
||||
|
||||
import qualified Operations
|
||||
|
||||
import Data.Query
|
||||
(Field(..))
|
||||
|
||||
commands :: Parser (BuukaM ())
|
||||
commands = subparser
|
||||
( command "insert" (info (insertOpts Operations.insert) (progDesc "Insert a new bookmark"))
|
||||
<> command "list" (info (pure Operations.list) (progDesc "List all the bookmarks"))
|
||||
( command "insert" (info (insertOpts Operations.insert <**> helper) (progDesc "Insert a new bookmark"))
|
||||
<> command "list" (info (pure Operations.list <**> helper) (progDesc "List all the bookmarks"))
|
||||
<> command "query" (info (queryOpts Operations.query <**> helper) (progDesc "Query the bookmarks"))
|
||||
)
|
||||
where
|
||||
insertOpts f =
|
||||
f <$> strOption (long "url" <> short 'u' <> metavar "URL")
|
||||
<*> optional (strOption (long "title"))
|
||||
queryOpts f =
|
||||
uncurry f <$> asum [tagged Title "title", tagged Url "url"]
|
||||
tagged t x = (t, ) <$> strOption (long x <> metavar "REGEX")
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
|
Reference in New Issue
Block a user