Skip to content

Commit

Permalink
allow custom success msg via -d:nimHintSuccessX:"custom msg out: $out…
Browse files Browse the repository at this point in the history
…put recompiled: $projectRecompiled"
  • Loading branch information
timotheecour committed Feb 27, 2020
1 parent 70f8174 commit 0f91dea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions compiler/commands.nim
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
splitSwitch(conf, arg, key, val, pass, info)
if cmpIgnoreStyle(key, "nimQuirky") == 0:
conf.exc = excQuirky
elif cmpIgnoreStyle(key, "nimHintSuccessX") == 0:
msgKindToStr[hintSuccessX] = val
defineSymbol(conf.symbols, key, val)
else:
if cmpIgnoreStyle(arg, "nimQuirky") == 0:
Expand Down
9 changes: 6 additions & 3 deletions compiler/lineinfos.nim
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ type
hintUser, hintUserRaw,
hintExtendedContext

const
MsgKindToStr*: array[TMsgKind, string] = [
var
msgKindToStr*: array[TMsgKind, string] = [
errUnknown: "unknown error",
errInternal: "internal error: $1",
errIllFormedAstX: "illformed AST: $1",
Expand Down Expand Up @@ -98,7 +98,10 @@ const
warnUser: "$1",
hintSuccess: "operation successful: $#",
# keep in sync with `testament.isSuccess`
hintSuccessX: "$loc LOC; $sec sec; $mem; $build build; proj: $project; out: $output recompiled: $projectRecompiled",
# can be overriden with -d:nimHintSuccessX:"custom msg; recompiled: $projectRecompiled"
# for the set of valid keys and details on formatting, see code near:
# `rawMessage(conf, hintSuccessX`
hintSuccessX: "$loc LOC; $sec sec; $mem; $build build; proj: $project; out: $output",
hintCC: "CC: \'$1\'", # unused
hintLineTooLong: "line too long",
hintXDeclaredButNotUsed: "'$1' is declared but not used",
Expand Down
2 changes: 1 addition & 1 deletion compiler/msgs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ proc coordToStr(coord: int): string =

proc msgKindToString*(kind: TMsgKind): string =
# later versions may provide translated error messages
result = MsgKindToStr[kind]
result = msgKindToStr[kind]

proc getMessageStr(msg: TMsgKind, arg: string): string =
result = msgKindToString(msg) % [arg]
Expand Down

0 comments on commit 0f91dea

Please sign in to comment.