From aa1b17d819aa81ae175185ab0e5be7fbfcff4f16 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 13 Jan 2026 03:56:12 +0100 Subject: main: admit $ref in config --- README.md | 7 +++++++ src/main.hs | 7 +++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f661d70..b448f3e 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,13 @@ "pass": "somepass" } + or, if the password should be read from a separate file containing a JSON value, then: + + { + "nick": "somenick", + "pass": { "$ref": "path/to/pass.json" } + } + then enter the Nix shell for development: cabal2nix . > default.nix && nix-shell -I stockholm=~/stockholm diff --git a/src/main.hs b/src/main.hs index b57d161..757f732 100644 --- a/src/main.hs +++ b/src/main.hs @@ -3,11 +3,9 @@ module Main (main) where import Control.Lens -import Data.Aeson -import Data.Aeson (Value) import Data.Aeson.Lens +import Data.Aeson.Reference (resolveReference) import Data.Aeson.Types -import Data.Text (Text) import Prelude.Extended import qualified Reaktor import qualified Reaktor.Plugins.Mention @@ -16,13 +14,14 @@ import qualified Reaktor.Plugins.Register import qualified Reaktor.Plugins.SASL import qualified Reaktor.Plugins.System import qualified System.Environment +import qualified Data.Text as Text main :: IO () main = do [configPath] <- System.Environment.getArgs - v <- preview _Value <$> readFile configPath + v <- either error (preview _Value) <$> resolveReference "." (Text.pack configPath) Reaktor.run (reaktorConfig v) (apiConfig v) $ \actions -> mapM id [ -- cgit v1.2.3