aboutsummaryrefslogtreecommitdiff
path: root/hsm-battery/Test/Battery.hs
diff options
context:
space:
mode:
Diffstat (limited to 'hsm-battery/Test/Battery.hs')
-rw-r--r--hsm-battery/Test/Battery.hs25
1 files changed, 25 insertions, 0 deletions
diff --git a/hsm-battery/Test/Battery.hs b/hsm-battery/Test/Battery.hs
new file mode 100644
index 0000000..caf24a6
--- /dev/null
+++ b/hsm-battery/Test/Battery.hs
@@ -0,0 +1,25 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+import Control.Concurrent (threadDelay)
+import Control.Monad (forever)
+import Data.Function ((&))
+import Effectful (liftIO, runEff)
+import Hsm.Battery (readBatteryState, runBattery)
+import Hsm.Core.App (bootstrapApp)
+import Hsm.Log (Severity (Info), logMsg, runLogsOpt)
+import Hsm.Log.Options (makeLoggerOptionParser)
+-- Import full module for cleaner `-ddump-splices` output
+-- Avoids package/module qualifiers in generated code
+import Options.Applicative
+
+type Logs = '["battery"]
+
+$(makeLoggerOptionParser @Logs "Options" "parser" 'Info)
+
+main :: IO ()
+main =
+ bootstrapApp parser "Launch Battery Monitoring Test Application" $ \opts ->
+ (forever $ liftIO (threadDelay 1000000) >> readBatteryState >>= logMsg Info . show)
+ & runBattery
+ & runLogsOpt @Options @Logs opts
+ & runEff