Do not require a command key in the config file

This commit is contained in:
Tom Sydney Kerckhove 2022-03-06 12:15:17 +01:00
parent 343ab6a5a8
commit 77bde208d8
2 changed files with 13 additions and 7 deletions

View File

@ -1,5 +1,3 @@
loops: loops:
ci: ci: nix-build ci.nix --no-out-link
command: nix-build ci.nix install: stack install
install:
command: stack install

View File

@ -1,5 +1,6 @@
{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-} {-# LANGUAGE DerivingVia #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedLists #-} {-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE RecordWildCards #-}
@ -97,9 +98,16 @@ data LoopConfiguration = LoopConfiguration
instance HasCodec LoopConfiguration where instance HasCodec LoopConfiguration where
codec = codec =
dimapCodec f g $
eitherCodec codec $
object "LoopConfiguration" $ object "LoopConfiguration" $
LoopConfiguration LoopConfiguration
<$> requiredField "command" "the command to run on change" .= loopConfigCommand <$> requiredField "command" "the command to run on change" .= loopConfigCommand
where
f = \case
Left command -> LoopConfiguration {loopConfigCommand = command}
Right loopConfig -> loopConfig
g (LoopConfiguration command) = Left command
data OutputConfiguration = OutputConfiguration data OutputConfiguration = OutputConfiguration
{ outputConfigClear :: !(Maybe Clear) { outputConfigClear :: !(Maybe Clear)