Fixes #290.
This commit is contained in:
parent
c46e3dcd4d
commit
bdfb681824
2 changed files with 18 additions and 1 deletions
|
|
@ -650,6 +650,7 @@ proc listPaths(options: Options) =
|
||||||
## but at the end quits with a non zero exit error.
|
## but at the end quits with a non zero exit error.
|
||||||
##
|
##
|
||||||
## On success the proc returns normally.
|
## On success the proc returns normally.
|
||||||
|
cli.setSuppressMessages(true)
|
||||||
assert options.action.typ == actionPath
|
assert options.action.typ == actionPath
|
||||||
assert(not options.action.packages.isNil)
|
assert(not options.action.packages.isNil)
|
||||||
|
|
||||||
|
|
@ -720,6 +721,7 @@ proc getPackageByPattern(pattern: string, options: Options): PackageInfo =
|
||||||
result = getPkgInfoFromFile(skeletonInfo.myPath, options)
|
result = getPkgInfoFromFile(skeletonInfo.myPath, options)
|
||||||
|
|
||||||
proc dump(options: Options) =
|
proc dump(options: Options) =
|
||||||
|
cli.setSuppressMessages(true)
|
||||||
let p = getPackageByPattern(options.action.projName, options)
|
let p = getPackageByPattern(options.action.projName, options)
|
||||||
echo "name: ", p.name.escape
|
echo "name: ", p.name.escape
|
||||||
echo "version: ", p.version.escape
|
echo "version: ", p.version.escape
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,10 @@ type
|
||||||
warnings: HashSet[(string, string)]
|
warnings: HashSet[(string, string)]
|
||||||
suppressionCount: int ## Amount of messages which were not shown.
|
suppressionCount: int ## Amount of messages which were not shown.
|
||||||
showColor: bool ## Whether messages should be colored.
|
showColor: bool ## Whether messages should be colored.
|
||||||
|
suppressMessages: bool ## Whether Warning, Message and Success messages
|
||||||
|
## should be suppressed, useful for
|
||||||
|
## commands like `dump` whose output should be
|
||||||
|
## machine readable.
|
||||||
|
|
||||||
Priority* = enum
|
Priority* = enum
|
||||||
DebugPriority, LowPriority, MediumPriority, HighPriority
|
DebugPriority, LowPriority, MediumPriority, HighPriority
|
||||||
|
|
@ -42,7 +46,8 @@ proc newCLI(): CLI =
|
||||||
level: HighPriority,
|
level: HighPriority,
|
||||||
warnings: initSet[(string, string)](),
|
warnings: initSet[(string, string)](),
|
||||||
suppressionCount: 0,
|
suppressionCount: 0,
|
||||||
showColor: true
|
showColor: true,
|
||||||
|
suppressMessages: false
|
||||||
)
|
)
|
||||||
|
|
||||||
var globalCLI = newCLI()
|
var globalCLI = newCLI()
|
||||||
|
|
@ -77,6 +82,13 @@ proc displayLine(category, line: string, displayType: DisplayType,
|
||||||
|
|
||||||
proc display*(category, msg: string, displayType = Message,
|
proc display*(category, msg: string, displayType = Message,
|
||||||
priority = MediumPriority) =
|
priority = MediumPriority) =
|
||||||
|
|
||||||
|
# Don't print any Warning, Message or Success messages when suppression of
|
||||||
|
# warnings is enabled. That is, unless the user asked for --verbose output.
|
||||||
|
if globalCLI.suppressMessages and displayType >= Warning and
|
||||||
|
globalCLI.level == HighPriority:
|
||||||
|
return
|
||||||
|
|
||||||
# Multiple warnings containing the same messages should not be shown.
|
# Multiple warnings containing the same messages should not be shown.
|
||||||
let warningPair = (category, msg)
|
let warningPair = (category, msg)
|
||||||
if displayType == Warning:
|
if displayType == Warning:
|
||||||
|
|
@ -155,6 +167,9 @@ proc setVerbosity*(level: Priority) =
|
||||||
proc setShowColor*(val: bool) =
|
proc setShowColor*(val: bool) =
|
||||||
globalCLI.showColor = val
|
globalCLI.showColor = val
|
||||||
|
|
||||||
|
proc setSuppressMessages*(val: bool) =
|
||||||
|
globalCLI.suppressMessages = val
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
display("Reading", "config file at /Users/dom/.config/nimble/nimble.ini",
|
display("Reading", "config file at /Users/dom/.config/nimble/nimble.ini",
|
||||||
priority = LowPriority)
|
priority = LowPriority)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue