Compare commits

..

3 Commits
4.0.1 ... 4.0.4

Author SHA1 Message Date
3bdb2ecb1f Fix padding issue in context listing. 2018-05-14 10:04:24 -05:00
28569a643e Added Dormant state, auto-create task dirs.
The Dormant state is for tasks that are still outstanding but not of
immediate importance. The main different between Dormant and Todo is
that dormant tasks are not listed by default. You must
`pit list dormant` to see them.
2018-05-14 09:53:15 -05:00
97eb286e32 Reorganize project folder structure to work according to nimble package expectations. 2018-05-14 09:36:23 -05:00
3 changed files with 19 additions and 9 deletions

View File

@ -1,6 +1,6 @@
# Package
version = "4.0.1"
version = "4.0.4"
author = "Jonathan Bernard"
description = "Personal issue tracker."
license = "MIT"

View File

@ -6,7 +6,7 @@ import cliutils, docopt, json, logging, options, os, ospaths, sequtils,
tables, terminal, times, unicode, uuids
import strutils except capitalize, toUpper, toLower
import pit/private/libpit
import pitpkg/private/libpit
export libpit
type
@ -112,12 +112,13 @@ proc writeSection(ctx: CliContext, issues: seq[Issue], state: IssueState,
stdout.writeLine("")
stdout.resetAttributes
var topPadded = true
let issuesByContext = issues.groupBy("context")
var topPadded = true
if issues.len > 5 and issuesByContext.len > 1:
for context, ctxIssues in issuesByContext:
topPadded = true
stdout.setForegroundColor(fgYellow, false)
stdout.writeLine(indent & ctx.getIssueContextDisplayName(context) & ":")
stdout.writeLine("")
@ -227,7 +228,7 @@ when isMainModule:
Usage:
pit ( new | add) <summary> [<state>] [options]
pit list [<state>] [options]
pit ( start | done | pending | do-today | todo ) <id>...
pit ( start | done | pending | do-today | todo | suspend ) <id>...
pit edit <id>
pit delete <id>...
@ -261,7 +262,7 @@ Options:
logging.addHandler(newConsoleLogger())
# Parse arguments
let args = docopt(doc, version = "pit 4.0.1")
let args = docopt(doc, version = "pit 4.0.4")
if args["--echo-args"]: stderr.writeLine($args)
@ -271,6 +272,11 @@ Options:
let ctx = initContext(args)
# Create our tasks directory structure if needed
for s in IssueState:
if not existsDir(ctx.tasksDir / $s):
(ctx.tasksDir / $s).createDir
## Actual command runners
if args["new"] or args["add"]:
let state =
@ -295,7 +301,7 @@ Options:
edit(ctx.tasksDir.loadIssueById(issueId))
elif args["start"] or args["do-today"] or args["done"] or
args["pending"] or args["todo"]:
args["pending"] or args["todo"] or args["suspend"]:
var targetState: IssueState
if args["done"]: targetState = Done
@ -303,6 +309,7 @@ Options:
elif args["pending"]: targetState = Todo
elif args["start"]: targetState = Current
elif args["todo"]: targetState = Todo
elif args["suspend"]: targetState = Dormant
for id in @(args["<id>"]):
ctx.tasksDir.loadIssueById(id).changeState(ctx.tasksDir, targetState)

View File

@ -15,6 +15,7 @@ type
Pending = "pending",
Done = "done",
Todo = "todo"
Dormant = "dormant"
IssueFilter* = ref object
properties*: TableRef[string, string]
@ -27,8 +28,9 @@ let ISSUE_FILE_PATTERN = re"[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f
proc displayName*(s: IssueState): string =
case s
of Current: result = "Current"
of Pending: result = "Pending"
of Done: result = "Done"
of Dormant: result = "Dormant"
of Pending: result = "Pending"
of Todo: result = "Todo"
of TodoToday: result = "Todo"
@ -161,9 +163,10 @@ proc loadIssues*(path: string): seq[Issue] =
result.add(loadIssue(path))
proc changeState*(issue: Issue, tasksDir: string, newState: IssueState) =
removeFile(issue.filepath)
let oldFilepath = issue.filepath
if newState == Done: issue.setDateTime("completed", getTime().local)
tasksDir.store(issue, newState)
removeFile(oldFilepath)
proc delete*(issue: Issue) = removeFile(issue.filepath)