Add tag
and untag
commands.
This commit is contained in:
parent
476a94c679
commit
db3e648d47
27
src/pit.nim
27
src/pit.nim
@ -5,7 +5,7 @@ import cliutils, docopt, json, logging, options, os, ospaths, sequtils,
|
|||||||
tables, terminal, times, timeutils, unicode, uuids
|
tables, terminal, times, timeutils, unicode, uuids
|
||||||
|
|
||||||
from nre import re
|
from nre import re
|
||||||
import strutils except capitalize, toUpper, toLower
|
import strutils except capitalize, strip, toUpper, toLower
|
||||||
import pitpkg/private/libpit
|
import pitpkg/private/libpit
|
||||||
export libpit
|
export libpit
|
||||||
|
|
||||||
@ -244,6 +244,8 @@ Usage:
|
|||||||
pit list [<listable>] [options]
|
pit list [<listable>] [options]
|
||||||
pit ( start | done | pending | todo-today | todo | suspend ) <id>... [options]
|
pit ( start | done | pending | todo-today | todo | suspend ) <id>... [options]
|
||||||
pit edit <ref>...
|
pit edit <ref>...
|
||||||
|
pit tag <id>... [options]
|
||||||
|
pit untag <id>... [options]
|
||||||
pit reorder <state>
|
pit reorder <state>
|
||||||
pit delegate <id> <delegated-to>
|
pit delegate <id> <delegated-to>
|
||||||
pit ( delete | rm ) <id>...
|
pit ( delete | rm ) <id>...
|
||||||
@ -357,6 +359,29 @@ Options:
|
|||||||
|
|
||||||
else: edit(ctx.tasksDir.loadIssueById(editRef))
|
else: edit(ctx.tasksDir.loadIssueById(editRef))
|
||||||
|
|
||||||
|
elif args["tag"]:
|
||||||
|
if not args["--tags"]: raise newException(Exception, "no tags given")
|
||||||
|
|
||||||
|
let newTags = ($args["--tags"]).split(",").mapIt(it.strip)
|
||||||
|
|
||||||
|
for id in @(args["<id>"]):
|
||||||
|
var issue = ctx.tasksDir.loadIssueById(id)
|
||||||
|
issue.tags = deduplicate(issue.tags & newTags)
|
||||||
|
issue.store()
|
||||||
|
|
||||||
|
elif args["untag"]:
|
||||||
|
let tagsToRemove: seq[string] =
|
||||||
|
if args["--tags"]: ($args["--tags"]).split(",").mapIt(it.strip)
|
||||||
|
else: @[]
|
||||||
|
|
||||||
|
for id in @(args["<id>"]):
|
||||||
|
var issue = ctx.tasksDir.loadIssueById(id)
|
||||||
|
if tagsToRemove.len > 0:
|
||||||
|
issue.tags = issue.tags.filter(
|
||||||
|
proc (tag: string): bool = not tagsToRemove.anyIt(it == tag))
|
||||||
|
else: issue.tags = @[]
|
||||||
|
issue.store()
|
||||||
|
|
||||||
elif args["start"] or args["todo-today"] or args["done"] or
|
elif args["start"] or args["todo-today"] or args["done"] or
|
||||||
args["pending"] or args["todo"] or args["suspend"]:
|
args["pending"] or args["todo"] or args["suspend"]:
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ proc store*(tasksDir: string, issue: Issue, state: IssueState, withComments = fa
|
|||||||
else:
|
else:
|
||||||
issue.filepath = stateDir / filename
|
issue.filepath = stateDir / filename
|
||||||
|
|
||||||
issue.store()
|
issue.store(withComments)
|
||||||
|
|
||||||
proc storeOrder*(issues: seq[Issue], path: string) =
|
proc storeOrder*(issues: seq[Issue], path: string) =
|
||||||
var orderLines = newSeq[string]()
|
var orderLines = newSeq[string]()
|
||||||
|
@ -1 +1 @@
|
|||||||
const PIT_VERSION* = "4.5.0"
|
const PIT_VERSION* = "4.6.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user