Skip to content

Commit

Permalink
bugfix - default for missing config objects
Browse files Browse the repository at this point in the history
  • Loading branch information
aviaviavi committed Nov 5, 2018
1 parent e538501 commit 9b18dc8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
20 changes: 14 additions & 6 deletions app/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}

{-# LANGUAGE TypeOperators #-}

module Server where
Expand All @@ -16,6 +17,7 @@ import qualified Control.Exception as E
import Control.Monad
import Control.Monad.IO.Class
import Data.Aeson (FromJSON)
import Data.Aeson.Types
import Data.Either
import Data.IORef
import Data.List (find, nub)
Expand All @@ -24,7 +26,6 @@ import Data.String.Utils
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Yaml as Y
import GHC.Generics (Generic)
import Servant
import System.Directory
import System.IO.HVFS
Expand All @@ -39,7 +40,14 @@ import Text.Regex.Posix
data ToodlesConfig = ToodlesConfig
{ ignore :: [FilePath]
, flags :: [UserFlag]
} deriving (Show, Generic, FromJSON)
} deriving (Show)

instance FromJSON ToodlesConfig where
parseJSON (Object o) = do
parsedIgnore <- o .:? "ignore" .!= []
parsedFlags <- o .:? "flags" .!= []
return $ ToodlesConfig parsedIgnore parsedFlags
parseJSON invalid = typeMismatch "Invalid config" invalid

app :: ToodlesState -> Application
app s = serve toodlesAPI server
Expand Down Expand Up @@ -143,10 +151,10 @@ renderTodo t =
listIfNotNull s = [s]

renderFlag :: Flag -> Text
renderFlag TODO = "TODO"
renderFlag FIXME = "FIXME"
renderFlag XXX = "XXX"
renderFlag (UF (UserFlag x)) = x
renderFlag TODO = "TODO"
renderFlag FIXME = "FIXME"
renderFlag XXX = "XXX"
renderFlag (UF (UserFlag x)) = x

-- | Given a function to emit new lines for a given todo, write that update in
-- place of the current todo lines
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: toodles
version: 0.1.1
version: 0.1.2
github: "aviaviavi/toodles"
license: MIT
author: "Avi Press"
Expand Down
4 changes: 2 additions & 2 deletions toodles.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: a9f9d2e470b32f019c6ac8a8a55e03313189492b36a710ce6a3fb4da7bb7178a
-- hash: c40e42a465ceb481a6828c3d022823ac5a955e9a52865832af413fd0c97ccb52

name: toodles
version: 0.1.1
version: 0.1.2
synopsis: Manage the TODO entries in your code
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!
category: Project Management
Expand Down

0 comments on commit 9b18dc8

Please sign in to comment.