buuka/app/Main.hs

29 lines
764 B
Haskell
Raw Normal View History

2020-12-30 18:35:47 +02:00
module Main where
2020-12-30 23:29:56 +02:00
import Options.Applicative
import Control.Monad.Buuka
(BuukaM, runBuukaM)
import Data.Environment
2020-12-31 08:31:31 +02:00
import UnliftIO.Directory
(XdgDirectory(XdgData), getXdgDirectory)
2020-12-30 23:29:56 +02:00
import qualified Operations
commands :: Parser (BuukaM ())
commands = subparser
2021-01-01 08:29:24 +02:00
( command "insert" (info (insertOpts Operations.insert) (progDesc "Insert a new bookmark"))
<> command "list" (info (pure Operations.list) (progDesc "List all the bookmarks"))
)
2020-12-30 23:29:56 +02:00
where
insertOpts f =
f <$> strOption (long "url" <> short 'u' <> metavar "URL")
<*> optional (strOption (long "title"))
2020-12-30 18:35:47 +02:00
main :: IO ()
main = do
2020-12-31 08:31:31 +02:00
env <- Environment <$> getXdgDirectory XdgData "buuka"
2020-12-30 23:29:56 +02:00
execParser (info (commands <**> helper) fullDesc) >>= runBuukaM env