added source function to add per-user configs

This commit is contained in:
Dmitry Zuikov 2024-09-15 11:20:03 +03:00
parent ff9ef2ddec
commit 84f801e6d6
3 changed files with 27 additions and 5 deletions

View File

@ -1 +1,2 @@
state.db
config.local

View File

@ -65,9 +65,7 @@ fixme-comments ";" "--"
(define (backlog s) (modify s workflow :backlog))
;; refchan settings
(refchan 3WtddmcE8zzgBAPR7Bu7mKMaVMTN423NNXSPUJp3Hx42)
(reader DTKxNwYCux7zHFLSvmEm5P3Ex21iQrrVdzJpR3giLh1D)
(author 3fKeGjaDGBKtNqeNBPsThh8vSj4TPiqaaK7uHbB8MQUV)
source ./config.local

View File

@ -434,9 +434,32 @@ runTop forms = do
_ -> void $ lift $ refchanExport ()
entry $ bindMatch "fixme:refchan:import" $ nil_ $ const $ lift do
void $ refchanImport
entry $ bindMatch "source" $ nil_ $ \case
[StringLike path] -> do
ppath <- if List.isPrefixOf "." path then do
dir <- localConfigDir
let rest = tail $ splitDirectories path
pure $ joinPath (dir:rest)
else do
canonicalizePath path
debug $ red "SOURCE FILE" <+> pretty ppath
dd <- readTVarIO tvd
-- FIXME: raise-warning?
content <- liftIO $ try @_ @IOException (readFile ppath)
<&> fromRight mempty
<&> parseTop
>>= either (error.show) pure
lift $ run dd content
_ -> throwIO $ BadFormException @C nil
entry $ bindMatch "update" $ nil_ $ const $ lift do
refchanUpdate
entry $ bindMatch "update" $ nil_ $ const $ lift do
refchanUpdate