diff --git a/src/pit.nim b/src/pit.nim index 3054fba..a306c88 100644 --- a/src/pit.nim +++ b/src/pit.nim @@ -5,7 +5,7 @@ import cliutils, docopt, json, logging, options, os, ospaths, sequtils, tables, terminal, times, timeutils, unicode, uuids from nre import re -import strutils except capitalize, toUpper, toLower +import strutils except capitalize, strip, toUpper, toLower import pitpkg/private/libpit export libpit @@ -244,6 +244,8 @@ Usage: pit list [] [options] pit ( start | done | pending | todo-today | todo | suspend ) ... [options] pit edit ... + pit tag ... [options] + pit untag ... [options] pit reorder pit delegate pit ( delete | rm ) ... @@ -357,6 +359,29 @@ Options: 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[""]): + 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[""]): + 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 args["pending"] or args["todo"] or args["suspend"]: diff --git a/src/pitpkg/private/libpit.nim b/src/pitpkg/private/libpit.nim index b1290b9..de2af68 100644 --- a/src/pitpkg/private/libpit.nim +++ b/src/pitpkg/private/libpit.nim @@ -179,7 +179,7 @@ proc store*(tasksDir: string, issue: Issue, state: IssueState, withComments = fa else: issue.filepath = stateDir / filename - issue.store() + issue.store(withComments) proc storeOrder*(issues: seq[Issue], path: string) = var orderLines = newSeq[string]() diff --git a/src/pitpkg/version.nim b/src/pitpkg/version.nim index c0e8316..894e1c5 100644 --- a/src/pitpkg/version.nim +++ b/src/pitpkg/version.nim @@ -1 +1 @@ -const PIT_VERSION* = "4.5.0" +const PIT_VERSION* = "4.6.0"