-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-| Data that we need when running the CLI | ||
-} | ||
module Wst.Cli.RuntimeEnv( | ||
RuntimeEnv(..), | ||
loadEnv, | ||
) where | ||
|
||
import Blammo.Logging (Logger) | ||
import Blammo.Logging.Logger (HasLogger (..), newLogger) | ||
import Blammo.Logging.LogSettings.Env qualified as LogSettingsEnv | ||
import Blockfrost.Auth (mkProject) | ||
import Blockfrost.Client.Auth qualified as Blockfrost | ||
import Control.Lens (makeLensesFor) | ||
import Data.Text qualified as Text | ||
import System.Environment qualified | ||
|
||
data RuntimeEnv | ||
= RuntimeEnv | ||
{ envLogger :: Logger | ||
, envBlockfrost :: Blockfrost.Project | ||
|
||
} | ||
|
||
makeLensesFor | ||
[ ("envLogger", "logger") | ||
, ("envBlockfrostProject", "blockfrostProject") | ||
] | ||
'RuntimeEnv | ||
|
||
instance HasLogger RuntimeEnv where | ||
loggerL = logger | ||
|
||
-- | Load the 'RuntimeEnv' from environment variables | ||
loadEnv :: IO RuntimeEnv | ||
loadEnv = | ||
RuntimeEnv | ||
<$> (LogSettingsEnv.parse >>= newLogger) | ||
<*> fmap (mkProject . Text.pack) (System.Environment.getEnv "WST_BLOCKFROST_TOKEN") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters