Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
49c5753ef1 | |||
3bdb2ecb1f | |||
28569a643e | |||
97eb286e32 |
@ -1,6 +1,6 @@
|
||||
# Package
|
||||
|
||||
version = "4.0.1"
|
||||
version = "4.0.5"
|
||||
author = "Jonathan Bernard"
|
||||
description = "Personal issue tracker."
|
||||
license = "MIT"
|
||||
|
23
src/pit.nim
23
src/pit.nim
@ -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,9 +228,9 @@ 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>...
|
||||
pit ( delete | rm ) <id>...
|
||||
|
||||
Options:
|
||||
|
||||
@ -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.5")
|
||||
|
||||
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)
|
||||
@ -316,7 +323,7 @@ Options:
|
||||
discard execShellCmd(cmd)
|
||||
elif targetState == Done: discard execShellCmd("ptk stop")
|
||||
|
||||
elif args["delete"]:
|
||||
elif args["delete"] or args["rm"]:
|
||||
for id in @(args["<id>"]):
|
||||
|
||||
let issue = ctx.tasksDir.loadIssueById(id)
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user