Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/1.2.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
smallhadroncollider committed May 25, 2018
2 parents 6b5fdaa + 3e5c927 commit ed1a74d
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/html/_config.yml
Expand Up @@ -3,7 +3,7 @@ title: taskell
tagline: Command-line Kanban board/task managment
baseurl: ""
locale: "en"
version: 1.2.5
version: 1.2.6
destination: _site/public
exclude: [deployment, Capfile, log, Gemfile, Gemfile.lock]

Expand Down
2 changes: 1 addition & 1 deletion package.yaml
@@ -1,5 +1,5 @@
name: taskell
version: '1.2.5.0'
version: '1.2.6.0'
category: CLI
author: Mark Wales
maintainer: mark@smallhadroncollider.com
Expand Down
2 changes: 1 addition & 1 deletion src/Config.hs
Expand Up @@ -8,7 +8,7 @@ import ClassyPrelude
import Data.FileEmbed (embedFile)

version :: Text
version = "1.2.5"
version = "1.2.6"

usage :: Text
usage = decodeUtf8 $(embedFile "templates/usage.txt")
9 changes: 8 additions & 1 deletion src/Data/Taskell/Lists.hs
Expand Up @@ -6,7 +6,7 @@ import ClassyPrelude hiding (empty)

import Data.Sequence as S ((!?), (|>), update, deleteAt)

import Data.Taskell.List (List(..), empty, extract, append, searchFor)
import Data.Taskell.List as L (List(..), empty, extract, append, searchFor, count)
import Data.Taskell.Task (Task)
import qualified Data.Taskell.Seq as S

Expand Down Expand Up @@ -57,3 +57,10 @@ appendToLast t ls = fromMaybe ls $ do
l <- ls !? i
let l' = append l t
return $ updateLists i ls l'

analyse :: Text -> Lists -> Text
analyse filepath ls = concat [
filepath , "\n"
, "Lists: ", tshow $ length ls, "\n"
, "Tasks: ", tshow $ foldl' (+) 0 (L.count <$> ls)
]
15 changes: 14 additions & 1 deletion src/IO/Taskell.hs
Expand Up @@ -9,7 +9,7 @@ import System.Directory (getCurrentDirectory, doesFileExist)
import Data.FileEmbed (embedFile)

import Config (version, usage)
import Data.Taskell.Lists (Lists, initial)
import Data.Taskell.Lists (Lists, initial, analyse)
import IO.Config (Config, general, filename, token, trello)
import IO.Markdown (stringify, parse)
import IO.Trello (TrelloBoardID, getCards)
Expand All @@ -23,6 +23,7 @@ parseArgs :: [Text] -> ReaderConfig Next
parseArgs ["-v"] = return $ Output version
parseArgs ["-h"] = return $ Output usage
parseArgs ["-t", boardID, file] = loadTrello boardID file
parseArgs ["-i", file] = fileInfo file
parseArgs [file] = loadFile file
parseArgs [] = (pack . filename . general <$> ask) >>= loadFile
parseArgs _ = return $ Output (unlines ["Invalid options", "", usage])
Expand Down Expand Up @@ -50,6 +51,18 @@ loadTrello boardID filepath = do
then return $ Output (filepath ++ " already exists")
else createTrello boardID path

fileInfo :: Text -> ReaderConfig Next
fileInfo filepath = do
let path = unpack filepath
exists' <- fileExists path
if exists'
then do
content <- readData path
return $ case content of
Right lists -> Output $ analyse filepath lists
Left err -> Output $ pack path ++ ": " ++ err
else return Exit

createTrello :: TrelloBoardID -> FilePath -> ReaderConfig Next
createTrello boardID path = do
config <- ask
Expand Down
9 changes: 5 additions & 4 deletions templates/usage.txt
@@ -1,7 +1,8 @@
Usage: taskell ([options] | [-t <trello-board-id>] file)
Usage: taskell ([options] | [-i | -t <trello-board-id>] file)

Options:

-h Help
-v Version number
-t <trello-board-id> Create a new taskell file from the given Trello board ID
-h Help
-v Version number
-i file Display information about a file
-t <trello-board-id> file Create a new taskell file from the given Trello board ID
7 changes: 7 additions & 0 deletions test/Data/Taskell/ListsTest.hs
Expand Up @@ -214,4 +214,11 @@ test_lists =
(appendToLast (T.new "Blah") empty)
)
]

, testCase "analyse" (
assertEqual
"Returns an analysis"
"test.md\nLists: 3\nTasks: 9"
(analyse "test.md" testLists)
)
]

0 comments on commit ed1a74d

Please sign in to comment.