Add show-dupes command, fix BareExcept warnings.
This commit is contained in:
29
src/pit.nim
29
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["<stateOrId>"]:
|
||||
try: statesOption = some(args["<stateOrId>"].mapIt(parseEnum[IssueState]($it)))
|
||||
except: issueIdsOption = some(args["<stateOrId>"].mapIt($it))
|
||||
try:
|
||||
statesOption =
|
||||
some(args["<stateOrId>"].
|
||||
mapIt(parseEnum[IssueState]($it)))
|
||||
except CatchableError:
|
||||
issueIdsOption = some(args["<stateOrId>"].mapIt($it))
|
||||
|
||||
# List the known contexts
|
||||
if listContexts:
|
||||
@@ -610,7 +614,22 @@ when isMainModule:
|
||||
try: write(propOut, decodeDataUri(issue[$(args["<propName>"])]))
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user