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
|
|
|
|
( command "insert" (info (insertOpts Operations.insert) (progDesc "Insert a new bookmark")))
|
|
|
|
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
|