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.
This commit is contained in:
parent
97eb286e32
commit
28569a643e
@ -1,6 +1,6 @@
|
|||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "4.0.2"
|
version = "4.0.3"
|
||||||
author = "Jonathan Bernard"
|
author = "Jonathan Bernard"
|
||||||
description = "Personal issue tracker."
|
description = "Personal issue tracker."
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
12
src/pit.nim
12
src/pit.nim
@ -227,7 +227,7 @@ when isMainModule:
|
|||||||
Usage:
|
Usage:
|
||||||
pit ( new | add) <summary> [<state>] [options]
|
pit ( new | add) <summary> [<state>] [options]
|
||||||
pit list [<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 edit <id>
|
||||||
pit delete <id>...
|
pit delete <id>...
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ Options:
|
|||||||
logging.addHandler(newConsoleLogger())
|
logging.addHandler(newConsoleLogger())
|
||||||
|
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
let args = docopt(doc, version = "pit 4.0.2")
|
let args = docopt(doc, version = "pit 4.0.3")
|
||||||
|
|
||||||
if args["--echo-args"]: stderr.writeLine($args)
|
if args["--echo-args"]: stderr.writeLine($args)
|
||||||
|
|
||||||
@ -271,6 +271,11 @@ Options:
|
|||||||
|
|
||||||
let ctx = initContext(args)
|
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
|
## Actual command runners
|
||||||
if args["new"] or args["add"]:
|
if args["new"] or args["add"]:
|
||||||
let state =
|
let state =
|
||||||
@ -295,7 +300,7 @@ Options:
|
|||||||
edit(ctx.tasksDir.loadIssueById(issueId))
|
edit(ctx.tasksDir.loadIssueById(issueId))
|
||||||
|
|
||||||
elif args["start"] or args["do-today"] or args["done"] or
|
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
|
var targetState: IssueState
|
||||||
if args["done"]: targetState = Done
|
if args["done"]: targetState = Done
|
||||||
@ -303,6 +308,7 @@ Options:
|
|||||||
elif args["pending"]: targetState = Todo
|
elif args["pending"]: targetState = Todo
|
||||||
elif args["start"]: targetState = Current
|
elif args["start"]: targetState = Current
|
||||||
elif args["todo"]: targetState = Todo
|
elif args["todo"]: targetState = Todo
|
||||||
|
elif args["suspend"]: targetState = Dormant
|
||||||
|
|
||||||
for id in @(args["<id>"]):
|
for id in @(args["<id>"]):
|
||||||
ctx.tasksDir.loadIssueById(id).changeState(ctx.tasksDir, targetState)
|
ctx.tasksDir.loadIssueById(id).changeState(ctx.tasksDir, targetState)
|
||||||
|
@ -15,6 +15,7 @@ type
|
|||||||
Pending = "pending",
|
Pending = "pending",
|
||||||
Done = "done",
|
Done = "done",
|
||||||
Todo = "todo"
|
Todo = "todo"
|
||||||
|
Dormant = "dormant"
|
||||||
|
|
||||||
IssueFilter* = ref object
|
IssueFilter* = ref object
|
||||||
properties*: TableRef[string, string]
|
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 =
|
proc displayName*(s: IssueState): string =
|
||||||
case s
|
case s
|
||||||
of Current: result = "Current"
|
of Current: result = "Current"
|
||||||
of Pending: result = "Pending"
|
|
||||||
of Done: result = "Done"
|
of Done: result = "Done"
|
||||||
|
of Dormant: result = "Dormant"
|
||||||
|
of Pending: result = "Pending"
|
||||||
of Todo: result = "Todo"
|
of Todo: result = "Todo"
|
||||||
of TodoToday: result = "Todo"
|
of TodoToday: result = "Todo"
|
||||||
|
|
||||||
@ -161,9 +163,10 @@ proc loadIssues*(path: string): seq[Issue] =
|
|||||||
result.add(loadIssue(path))
|
result.add(loadIssue(path))
|
||||||
|
|
||||||
proc changeState*(issue: Issue, tasksDir: string, newState: IssueState) =
|
proc changeState*(issue: Issue, tasksDir: string, newState: IssueState) =
|
||||||
removeFile(issue.filepath)
|
let oldFilepath = issue.filepath
|
||||||
if newState == Done: issue.setDateTime("completed", getTime().local)
|
if newState == Done: issue.setDateTime("completed", getTime().local)
|
||||||
tasksDir.store(issue, newState)
|
tasksDir.store(issue, newState)
|
||||||
|
removeFile(oldFilepath)
|
||||||
|
|
||||||
proc delete*(issue: Issue) = removeFile(issue.filepath)
|
proc delete*(issue: Issue) = removeFile(issue.filepath)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user