module Main where import Options.Applicative import Control.Monad.Buuka (BuukaM, runBuukaM) import Data.Environment import UnliftIO.Directory (XdgDirectory(XdgData), getXdgDirectory) import qualified Operations 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")) ) where insertOpts f = f <$> strOption (long "url" <> short 'u' <> metavar "URL") <*> optional (strOption (long "title")) main :: IO () main = do env <- Environment <$> getXdgDirectory XdgData "buuka" execParser (info (commands <**> helper) fullDesc) >>= runBuukaM env