From cb7ffaa2ff32132db224dfe020aca45fcf418df3 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Thu, 27 Feb 2020 17:38:25 -0800 Subject: [PATCH] use instead getConfigVar, ie: --msgs.hintSuccessX:customMsg --- compiler/commands.nim | 2 -- compiler/lineinfos.nim | 10 +++------- compiler/main.nim | 6 +++++- compiler/msgs.nim | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/compiler/commands.nim b/compiler/commands.nim index 1f50357e680cf..935d7e2be5f85 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -436,8 +436,6 @@ 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: diff --git a/compiler/lineinfos.nim b/compiler/lineinfos.nim index 90cda42da3ff6..96e22c3005c71 100644 --- a/compiler/lineinfos.nim +++ b/compiler/lineinfos.nim @@ -50,8 +50,8 @@ type hintUser, hintUserRaw, hintExtendedContext -var - msgKindToStr*: array[TMsgKind, string] = [ +const + MsgKindToStr*: array[TMsgKind, string] = [ errUnknown: "unknown error", errInternal: "internal error: $1", errIllFormedAstX: "illformed AST: $1", @@ -97,11 +97,7 @@ var warnCycleCreated: "$1", warnUser: "$1", hintSuccess: "operation successful: $#", - # keep in sync with `testament.isSuccess` - # 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", + hintSuccessX: "$1", # keep in sync with `testament.isSuccess` hintCC: "CC: $1", hintLineTooLong: "line too long", hintXDeclaredButNotUsed: "'$1' is declared but not used", diff --git a/compiler/main.nim b/compiler/main.nim index ea53e41fae5c5..d6698c4498017 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -373,7 +373,11 @@ proc mainCommand*(graph: ModuleGraph) = let project = if optListFullPaths in conf.globalOptions: $conf.projectFull else: $conf.projectName var output = $conf.absOutFile if optListFullPaths notin conf.globalOptions: output = output.AbsoluteFile.extractFilename - rawMessage(conf, hintSuccessX, [ + + let fmtDefault = "$loc LOC; $sec sec; $mem; $build build; proj: $project; out: $output" + # can be overriden to format differently/show additional fields + let msg = getConfigVar(conf, "msgs.hintSuccessX", fmtDefault) + rawMessage(conf, hintSuccessX, msg % [ "loc", loc, "sec", sec, "mem", mem, diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 34361e36e3ab3..6d1ecb2b14e4e 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -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]