taskwarrior 0.1.0.0 → 0.1.1.0
raw patch · 4 files changed
+54/−9 lines, 4 filesdep +randomdep ~base
Dependencies added: random
Dependency ranges changed: base
Files
- CHANGELOG.md +6/−2
- src/Taskwarrior/IO.hs +20/−1
- src/Taskwarrior/Task.hs +21/−0
- taskwarrior.cabal +7/−6
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for taskwarrior -## 0.1.0.0 -- YYYY-mm-dd+## 0.1.1.0 -- 2019-12-06 -* First version. Released on an unsuspecting world.+* Added `makeTask` and `createTask` functions.++## 0.1.0.0 -- 2019-11-08++* First version. Includes the data types, `saveTasks` and `getTasks`.
src/Taskwarrior/IO.hs view
@@ -4,10 +4,13 @@ module Taskwarrior.IO ( getTasks , saveTasks+ , createTask ) where -import Taskwarrior.Task ( Task )+import Taskwarrior.Task ( Task+ , makeTask+ ) import Data.Text ( Text ) import qualified Data.Text as Text import qualified Data.ByteString.Lazy as LBS@@ -21,6 +24,10 @@ import System.IO ( hClose ) import System.Exit ( ExitCode(..) ) import Control.Monad ( when )+import System.Random ( getStdRandom+ , random+ )+import Data.Time ( getCurrentTime ) -- | Uses task export with a given filter like ["description:Milk", "+PENDING"]. getTasks :: [Text] -> IO [Task]@@ -50,3 +57,15 @@ hClose stdin exitCode <- waitForProcess process when (exitCode /= ExitSuccess) $ fail . show $ exitCode++-- | This will create a Task. I runs in IO to create a UUID and get the currentTime. This will not save the Task to taskwarrior.+-- If you want to create a task, with certain fields and save it, you could do that like this:+-- @+-- newTask <- createTask "Buy Milk"+-- saveTasks [newTask { tags = ["groceries"] }]+-- @+createTask :: Text -> IO Task+createTask description = do+ uuid <- getStdRandom random+ entry <- getCurrentTime+ pure $ makeTask uuid entry description
src/Taskwarrior/Task.hs view
@@ -1,8 +1,10 @@+{-# LANGUAGE NamedFieldPuns #-} -- | This Module exports the main datatype of this library: Task. -- It is provided with FromJSON and ToJSON instances. module Taskwarrior.Task ( Task(..) , Tag+ , makeTask ) where @@ -153,3 +155,22 @@ ifNotNullList list f = (Semigroup.stimesMonoid . (fromBool :: Bool -> Integer) . not . null $ list) [f list]++-- | Makes a Task with the given mandatory fields uuid, entry time and description. See createTask for a non-pure version which needs less parameters.+makeTask :: UUID -> UTCTime -> Text -> Task+makeTask uuid entry description = Task { uuid+ , description+ , entry+ , modified = Just entry+ , status = Status.Pending+ , due = Nothing+ , priority = Nothing+ , project = Nothing+ , start = Nothing+ , scheduled = Nothing+ , until = Nothing+ , annotations = []+ , depends = []+ , tags = []+ , uda = HashMap.empty+ }
taskwarrior.cabal view
@@ -4,7 +4,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.1.0.0+version: 0.1.1.0 synopsis: Types and aeson instances for taskwarrior tasks description: Types and aeson instances for the https://taskwarrior.org task import/export feature@@ -13,8 +13,8 @@ bug-reports: https://github.com/maralorn/haskell-taskwarrior/issues license: AGPL-3.0-or-later license-file: LICENSE-author: Malte Brandy-maintainer: malte.brandy@maralorn.de+author: Malte Brandy <malte.brandy@maralorn.de>+maintainer: Malte Brandy <malte.brandy@maralorn.de> category: Taskwarrior, Data extra-source-files: CHANGELOG.md@@ -39,14 +39,15 @@ RecordWildCards build-depends:- , aeson ^>=1.4.5.0- , base >=4.12 && <4.14+ , aeson ^>=1.4.2.0+ , base >=4.11 && <4.14 , bytestring ^>=0.10.8.2 , process ^>=1.6.5.0+ , random ^>=1.1 , string-interpolate ^>=0.1.0.1 , text ^>=1.2.3.1 , time >=1.8.0.2 && <1.10- , unordered-containers ^>=0.2.10.0+ , unordered-containers ^>=0.2.9.0 , uuid ^>=1.3.13 hs-source-dirs: src