Skip to content

Commit 9b18dc8

Browse files
committed
bugfix - default for missing config objects
1 parent e538501 commit 9b18dc8

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

app/Server.hs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{-# LANGUAGE DeriveGeneric #-}
44
{-# LANGUAGE OverloadedStrings #-}
55
{-# LANGUAGE ScopedTypeVariables #-}
6+
67
{-# LANGUAGE TypeOperators #-}
78

89
module Server where
@@ -16,6 +17,7 @@ import qualified Control.Exception as E
1617
import Control.Monad
1718
import Control.Monad.IO.Class
1819
import Data.Aeson (FromJSON)
20+
import Data.Aeson.Types
1921
import Data.Either
2022
import Data.IORef
2123
import Data.List (find, nub)
@@ -24,7 +26,6 @@ import Data.String.Utils
2426
import Data.Text (Text)
2527
import qualified Data.Text as T
2628
import qualified Data.Yaml as Y
27-
import GHC.Generics (Generic)
2829
import Servant
2930
import System.Directory
3031
import System.IO.HVFS
@@ -39,7 +40,14 @@ import Text.Regex.Posix
3940
data ToodlesConfig = ToodlesConfig
4041
{ ignore :: [FilePath]
4142
, flags :: [UserFlag]
42-
} deriving (Show, Generic, FromJSON)
43+
} deriving (Show)
44+
45+
instance FromJSON ToodlesConfig where
46+
parseJSON (Object o) = do
47+
parsedIgnore <- o .:? "ignore" .!= []
48+
parsedFlags <- o .:? "flags" .!= []
49+
return $ ToodlesConfig parsedIgnore parsedFlags
50+
parseJSON invalid = typeMismatch "Invalid config" invalid
4351

4452
app :: ToodlesState -> Application
4553
app s = serve toodlesAPI server
@@ -143,10 +151,10 @@ renderTodo t =
143151
listIfNotNull s = [s]
144152

145153
renderFlag :: Flag -> Text
146-
renderFlag TODO = "TODO"
147-
renderFlag FIXME = "FIXME"
148-
renderFlag XXX = "XXX"
149-
renderFlag (UF (UserFlag x)) = x
154+
renderFlag TODO = "TODO"
155+
renderFlag FIXME = "FIXME"
156+
renderFlag XXX = "XXX"
157+
renderFlag (UF (UserFlag x)) = x
150158

151159
-- | Given a function to emit new lines for a given todo, write that update in
152160
-- place of the current todo lines

package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: toodles
2-
version: 0.1.1
2+
version: 0.1.2
33
github: "aviaviavi/toodles"
44
license: MIT
55
author: "Avi Press"

toodles.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ cabal-version: 1.12
44
--
55
-- see: https://github.com/sol/hpack
66
--
7-
-- hash: a9f9d2e470b32f019c6ac8a8a55e03313189492b36a710ce6a3fb4da7bb7178a
7+
-- hash: c40e42a465ceb481a6828c3d022823ac5a955e9a52865832af413fd0c97ccb52
88

99
name: toodles
10-
version: 0.1.1
10+
version: 0.1.2
1111
synopsis: Manage the TODO entries in your code
1212
description: Toodles scrapes your entire repository for TODO entries and organizes them so you can manage your project directly from the code. View, filter, sort, and edit your TODO\'s with an easy to use web application. When you make changes via toodles, the edits will be applied directly the TODO entries in your code. When you\'re done, commit and push your changes to share them with your team!
1313
category: Project Management

0 commit comments

Comments
 (0)