diff --git a/pit.nimble b/pit.nimble index 4c64392..65ef576 100644 --- a/pit.nimble +++ b/pit.nimble @@ -1,6 +1,6 @@ # Package -version = "4.23.3" +version = "4.23.4" author = "Jonathan Bernard" description = "Personal issue tracker." license = "MIT" diff --git a/src/pit.nim b/src/pit.nim index df81a97..2fdba39 100644 --- a/src/pit.nim +++ b/src/pit.nim @@ -226,7 +226,7 @@ proc edit(issue: Issue) = # Try to parse the newly-edited issue to make sure it was successful. let editedIssue = loadIssue(issue.filepath) editedIssue.store() - except: + except CatchableError: fatal "updated issue is invalid (ignoring edits): \n\t" & getCurrentExceptionMsg() issue.store() @@ -392,7 +392,7 @@ when isMainModule: var stateOption = none(IssueState) try: stateOption = some(parseEnum[IssueState](editRef)) - except: discard + except CatchableError: discard if stateOption.isSome: let state = stateOption.get @@ -545,8 +545,12 @@ when isMainModule: if args["contexts"]: listContexts = true elif args[""]: - try: statesOption = some(args[""].mapIt(parseEnum[IssueState]($it))) - except: issueIdsOption = some(args[""].mapIt($it)) + try: + statesOption = + some(args[""]. + mapIt(parseEnum[IssueState]($it))) + except CatchableError: + issueIdsOption = some(args[""].mapIt($it)) # List the known contexts if listContexts: @@ -610,7 +614,22 @@ when isMainModule: try: write(propOut, decodeDataUri(issue[$(args[""])])) finally: close(propOut) - except: + elif args["show-dupes"]: + ctx.loadAllIssues() + + var idsToPaths = newTable[string, var seq[string]]() + for (state, issues) in pairs(ctx.issues): + for issue in issues: + let issueId = $issue.id + + if idsToPaths.hasKey(issueId): idsToPaths[issueId].add(issue.filepath) + else: idsToPaths[issueId] = @[issue.filepath] + + for (issueId, issuePaths) in pairs(idsToPaths): + if issuePaths.len < 2: continue + stdout.writeLine(issueId & ":\p " & issuePaths.join("\p ") & "\p\p") + + except CatchableError: fatal getCurrentExceptionMsg() debug getCurrentException().getStackTrace() #raise getCurrentException() diff --git a/src/pitpkg/cliconstants.nim b/src/pitpkg/cliconstants.nim index df4b9d1..21355e4 100644 --- a/src/pitpkg/cliconstants.nim +++ b/src/pitpkg/cliconstants.nim @@ -1,4 +1,4 @@ -const PIT_VERSION* = "4.23.3" +const PIT_VERSION* = "4.23.4" const USAGE* = """Usage: pit ( new | add) [] [options] @@ -14,6 +14,7 @@ const USAGE* = """Usage: pit ( delete | rm ) ... [options] pit add-binary-property [options] pit get-binary-property [options] + pit show-dupes pit help [options] Options: diff --git a/src/pitpkg/private/libpit.nim b/src/pitpkg/private/libpit.nim index 521ee36..f86ad8c 100644 --- a/src/pitpkg/private/libpit.nim +++ b/src/pitpkg/private/libpit.nim @@ -168,7 +168,7 @@ proc parseDate*(d: string): DateTime = var errMsg = "" for df in DATE_FORMATS: try: return d.parse(df) - except: + except CatchableError: errMsg &= "\n\tTried " & df & " with " & d continue raise newException(ValueError, "Unable to parse input as a date: " & d & errMsg) @@ -426,7 +426,7 @@ proc loadConfig*(args: Table[string, Value] = initTable[string, Value]()): PitCo try: cfgFile = open(pitrcFilename, fmWrite) cfgFile.write("{\"tasksDir\": \"/path/to/tasks\"}") - except: warn "could not write default .pitrc to " & pitrcFilename + except CatchableError: warn "could not write default .pitrc to " & pitrcFilename finally: close(cfgFile) debug "loading config from '$#'" % [pitrcFilename]