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:
ci:
command: nix-build ci.nix
install:
command: stack install
ci: nix-build ci.nix --no-out-link
install: stack install

View File

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