Use an override for home if it exists

This commit is contained in:
Mats Rauhala 2021-01-02 23:07:10 +02:00
parent e802f66599
commit 1906ce9964

View File

@ -10,6 +10,9 @@ import Data.Environment
import UnliftIO.Directory import UnliftIO.Directory
(XdgDirectory(XdgData), getXdgDirectory) (XdgDirectory(XdgData), getXdgDirectory)
import System.Environment
(lookupEnv)
import qualified Operations import qualified Operations
commands :: Parser (BuukaM ()) commands :: Parser (BuukaM ())
@ -24,5 +27,8 @@ commands = subparser
main :: IO () main :: IO ()
main = do main = do
env <- Environment <$> getXdgDirectory XdgData "buuka" env <- Environment <$> (lookupEnv "BUUKA_HOME" >>= maybe defaultHome pure)
execParser (info (commands <**> helper) fullDesc) >>= runBuukaM env execParser (info (commands <**> helper) (fullDesc <> progDesc description)) >>= runBuukaM env
where
defaultHome = getXdgDirectory XdgData "buuka"
description = "Bookmarks manager. Stores the bookmarks in a yaml file under your xdg directory or in a folder specified by the BUUKA_HOME environment variable"