aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Main.hs2
-rw-r--r--app/Settings.hs43
2 files changed, 45 insertions, 0 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 274bfa4..3e9dc1d 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -459,6 +459,7 @@ import Prettyprinter ((<+>))
import Prettyprinter qualified as P
import Prettyprinter.Render.Terminal qualified as P
import Process (proc, sh_, textInput)
+import Settings (Settings (..), readSettings)
import System.Console.Terminal.Size qualified as Terminal
import System.Exit (ExitCode (ExitFailure), exitWith)
import System.IO (hClose, hFlush)
@@ -600,6 +601,7 @@ die s = do
main :: IO ()
main = do
+ settings <- readSettings
O.execParser (O.info (options <**> O.helper) O.idm) >>= \case
Options {colorize, noPager, width, command = List {sort, filters, files}} -> do
let withinPath issue = if null files then True else any (\file -> file `isPrefixOf` issue.file) files
diff --git a/app/Settings.hs b/app/Settings.hs
new file mode 100644
index 0000000..116a3d2
--- /dev/null
+++ b/app/Settings.hs
@@ -0,0 +1,43 @@
+module Settings
+ ( Settings,
+ readSettings,
+ )
+where
+
+import Data.Aeson qualified as A
+import Data.Yaml (decodeFileThrow)
+import GHC.Generics (Generic)
+import System.Directory (doesFileExist)
+import System.Environment.XDG.BaseDir (getSystemConfigFiles, getUserConfigFile)
+
+data Settings = Settings
+ {
+ }
+ deriving (Show, Generic)
+
+instance Semigroup Settings where
+ _ <> _ = Settings {}
+
+instance Monoid Settings where
+ mempty = Settings {}
+
+instance A.FromJSON Settings
+
+instance A.ToJSON Settings
+
+readSettings :: IO Settings
+readSettings =
+ fmap mconcat
+ . mapM
+ ( \fp ->
+ doesFileExist fp >>= \case
+ True -> decodeFileThrow fp
+ False -> pure mempty
+ )
+ =<< concat
+ <$> sequence
+ [ getSystemConfigFiles "anissue" "settings.yaml",
+ ((: []) <$> getUserConfigFile "anissue" "settings.yaml"),
+ -- TODO Read settings from Git base dir
+ pure ["./anissue.yaml"]
+ ]