taskwarrior 0.1.1.0 → 0.1.2.0
raw patch · 3 files changed
+32/−7 lines, 3 filesdep ~string-interpolate
Dependency ranges changed: string-interpolate
Files
- CHANGELOG.md +4/−0
- src/Taskwarrior/IO.hs +26/−5
- taskwarrior.cabal +2/−2
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for taskwarrior +## 0.1.2.0 -- 2019-12-23++* Added `getUUIDs` function.+ ## 0.1.1.0 -- 2019-12-06 * Added `makeTask` and `createTask` functions.
src/Taskwarrior/IO.hs view
@@ -5,6 +5,7 @@ ( getTasks , saveTasks , createTask+ , getUUIDs ) where @@ -14,6 +15,7 @@ import Data.Text ( Text ) import qualified Data.Text as Text import qualified Data.ByteString.Lazy as LBS+import qualified Data.ByteString.Lazy.Char8 as LBS import qualified Data.Aeson as Aeson import System.Process ( withCreateProcess , CreateProcess(..)@@ -28,8 +30,10 @@ , random ) import Data.Time ( getCurrentTime )+import Data.UUID ( UUID )+import qualified Data.UUID as UUID --- | Uses task export with a given filter like ["description:Milk", "+PENDING"].+-- | Uses `task export` with a given filter like `["description:Milk", "+PENDING"]`. getTasks :: [Text] -> IO [Task] getTasks args = withCreateProcess@@ -45,6 +49,24 @@ input <- LBS.hGetContents stdout either fail return . Aeson.eitherDecode $ input +-- | Gives all uuids matching the given filter (e.g. `["description:Milk", "+PENDING"]`). This calls the `task` binary.+getUUIDs :: [Text] -> IO [UUID]+getUUIDs args =+ withCreateProcess+ ((proc "task" (fmap Text.unpack . (++ ["_uuid"]) $ args)) { std_out = CreatePipe+ }+ )+ $ \_ stdoutMay _ _ -> do+ stdout <- maybe+ (fail "Couldn‘t create stdout handle for `task _uuid`")+ pure+ stdoutMay+ input <- LBS.hGetContents stdout+ maybe (fail "Couldn't parse UUIDs") return+ . traverse UUID.fromLazyASCIIBytes+ . LBS.lines+ $ input+ -- | Uses task import to save the given tasks. saveTasks :: [Task] -> IO () saveTasks tasks =@@ -60,10 +82,9 @@ -- | 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"] }]--- @+--+-- > newTask <- createTask "Buy Milk"+-- > saveTasks [newTask { tags = ["groceries"] }] createTask :: Text -> IO Task createTask description = do uuid <- getStdRandom random
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.1.0+version: 0.1.2.0 synopsis: Types and aeson instances for taskwarrior tasks description: Types and aeson instances for the https://taskwarrior.org task import/export feature@@ -44,7 +44,7 @@ , bytestring ^>=0.10.8.2 , process ^>=1.6.5.0 , random ^>=1.1- , string-interpolate ^>=0.1.0.1+ , string-interpolate >=0.1.0.0 && <0.3 , text ^>=1.2.3.1 , time >=1.8.0.2 && <1.10 , unordered-containers ^>=0.2.9.0