From 445ecfe9461029184c1e710902262e2149a3564b Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Sat, 21 Sep 2019 13:02:04 +0100 Subject: [PATCH] Fixes #649. The `dump` command now has implicit `-y`. --- src/nimblepkg/cli.nim | 19 +++++++++++++------ src/nimblepkg/options.nim | 6 ++++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/nimblepkg/cli.nim b/src/nimblepkg/cli.nim index a3ac714..3afda35 100644 --- a/src/nimblepkg/cli.nim +++ b/src/nimblepkg/cli.nim @@ -62,8 +62,18 @@ proc calculateCategoryOffset(category: string): int = assert category.len <= longestCategory return longestCategory - category.len +proc isSuppressed(displayType: DisplayType): bool = + # 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 true + proc displayCategory(category: string, displayType: DisplayType, priority: Priority) = + if isSuppressed(displayType): + return + # Calculate how much the `category` must be offset to align along a center # line. let offset = calculateCategoryOffset(category) @@ -80,6 +90,9 @@ proc displayCategory(category: string, displayType: DisplayType, proc displayLine(category, line: string, displayType: DisplayType, priority: Priority) = + if isSuppressed(displayType): + return + displayCategory(category, displayType, priority) # Display the message. @@ -87,12 +100,6 @@ proc displayLine(category, line: string, displayType: DisplayType, proc display*(category, msg: string, displayType = Message, 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. let warningPair = (category, msg) if displayType == Warning: diff --git a/src/nimblepkg/options.nim b/src/nimblepkg/options.nim index 6ef2f95..3482f34 100644 --- a/src/nimblepkg/options.nim +++ b/src/nimblepkg/options.nim @@ -187,6 +187,7 @@ proc initAction*(options: var Options, key: string) = options.action.projName = "" of actionDump: options.action.projName = "" + options.forcePrompts = forcePromptYes of actionRefresh: options.action.optionalURL = "" of actionSearch: @@ -264,8 +265,9 @@ proc parseArgument*(key: string, result: var Options) = result.action.search.add(key) of actionInit, actionDump: if result.action.projName != "": - raise newException(NimbleError, - "Can only initialize one package at a time.") + raise newException( + NimbleError, "Can only perform this action on one package at a time." + ) result.action.projName = key of actionCompile, actionDoc: result.action.file = key