【问题标题】:How to clean error message in Nim? Silence hints?如何清除 Nim 中的错误消息?沉默提示?
【发布时间】:2020-08-19 17:08:48
【问题描述】:

这个错误的代码

import sequtils, sugar, yaml

let a: int
a = ""

产生巨大的错误信息

$ nimble run
  Verifying dependencies for nim@1
      Info: Dependency on yaml@any version already satisfied
  Verifying dependencies for yaml@0.14.0
   Building nim/app using c backend
       Tip: 3 messages have been suppressed, use --verbose to show them.
     Error: Build failed for package: nim
        ... Details:
        ... Execution failed with exit code 1
        ... Command: "/usr/local/Cellar/nim/1.2.6/nim/bin/nim" c --noNimblePath -d:NimblePkgVersion=1 --path:"/Users/alex/.nimble/pkgs/yaml-0.14.0"  -o:"/alex/projects/alien/old/nim/app" "/alex/projects/alien/old/nim/src/app.nim"
        ... Output: Hint: used config file '/usr/local/Cellar/nim/1.2.6/nim/config/nim.cfg' [Conf]
        ... Hint: system [Processing]
        ... Hint: widestrs [Processing]
        ... Hint: io [Processing]
        ... Hint: app [Processing]
        ... Hint: base [Processing]
        ... Hint: sequtils [Processing]
        ... Hint: macros [Processing]
        ... Hint: sugar [Processing]
        ... Hint: typetraits [Processing]
        ... Hint: underscored_calls [Processing]
        ... Hint: yaml [Processing]
        ... Hint: dom [Processing]
        ... Hint: tables [Processing]
        ... Hint: hashes [Processing]
        ... Hint: math [Processing]
        ... Hint: bitops [Processing]
        ... Hint: algorithm [Processing]
        ... Hint: streams [Processing]
        ... Hint: sets [Processing]
        ... Hint: strutils [Processing]
        ... Hint: parseutils [Processing]
        ... Hint: unicode [Processing]
        ... Hint: stream [Processing]
        ... Hint: internal [Processing]
        ... Hint: taglib [Processing]
        ... Hint: serialization [Processing]
        ... Hint: times [Processing]
        ... Hint: options [Processing]
        ... Hint: posix [Processing]
        ... Hint: parser [Processing]
        ... Hint: lex [Processing]
        ... Hint: lexbase [Processing]
        ... Hint: presenter [Processing]
        ... Hint: deques [Processing]
        ... Hint: hints [Processing]
        ... Hint: annotations [Processing]
        ... Hint: tojson [Processing]
        ... Hint: json [Processing]
        ... Hint: parsejson [Processing]
        ... /alex/projects/nim/src/test.nim(3, 5) Error: 'let' symbol requires an initialization

是否可以使非必要的输出静音而只显示错误消息?喜欢

        ... /alex/projects/nim/src/test.nim(3, 5) Error: 'let' symbol requires an initialization

【问题讨论】:

    标签: nim-lang


    【解决方案1】:

    要使用编译器获得该行为,您将使用两个参数:

    nim c --hints:off --verbosity:0 -r something.nim
    

    您可以将其添加到 a compiler configuration file,如果这是您唯一需要的,您就不需要灵活。

    关于 nimble,来自 it's changelog it seems the verbosity of commands has changed over time,查看相同的编译器参数是否适用于 nimble,如果不适用,请创建问题以请求此类行为。

    【讨论】:

      【解决方案2】:

      这部分有助于nimble --hints:off run

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-02-18
        • 1970-01-01
        • 1970-01-01
        • 2014-06-07
        • 1970-01-01
        相关资源
        最近更新 更多