From 1906ce996489232ff6540cb8304c9528ffcee11b Mon Sep 17 00:00:00 2001 From: Mats Rauhala Date: Sat, 2 Jan 2021 23:07:10 +0200 Subject: [PATCH] Use an override for home if it exists --- app/Main.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index 0a27393..d82cd6a 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -10,6 +10,9 @@ import Data.Environment import UnliftIO.Directory (XdgDirectory(XdgData), getXdgDirectory) +import System.Environment + (lookupEnv) + import qualified Operations commands :: Parser (BuukaM ()) @@ -24,5 +27,8 @@ commands = subparser main :: IO () main = do - env <- Environment <$> getXdgDirectory XdgData "buuka" - execParser (info (commands <**> helper) fullDesc) >>= runBuukaM env + env <- Environment <$> (lookupEnv "BUUKA_HOME" >>= maybe defaultHome pure) + 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"