Fixes #649. The dump command now has implicit -y.

This commit is contained in:
Dominik Picheta 2019-09-21 13:02:04 +01:00
commit 445ecfe946
2 changed files with 17 additions and 8 deletions

View file

@ -62,8 +62,18 @@ proc calculateCategoryOffset(category: string): int =
assert category.len <= longestCategory assert category.len <= longestCategory
return longestCategory - category.len 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, proc displayCategory(category: string, displayType: DisplayType,
priority: Priority) = priority: Priority) =
if isSuppressed(displayType):
return
# Calculate how much the `category` must be offset to align along a center # Calculate how much the `category` must be offset to align along a center
# line. # line.
let offset = calculateCategoryOffset(category) let offset = calculateCategoryOffset(category)
@ -80,6 +90,9 @@ proc displayCategory(category: string, displayType: DisplayType,
proc displayLine(category, line: string, displayType: DisplayType, proc displayLine(category, line: string, displayType: DisplayType,
priority: Priority) = priority: Priority) =
if isSuppressed(displayType):
return
displayCategory(category, displayType, priority) displayCategory(category, displayType, priority)
# Display the message. # Display the message.
@ -87,12 +100,6 @@ 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:

View file

@ -187,6 +187,7 @@ proc initAction*(options: var Options, key: string) =
options.action.projName = "" options.action.projName = ""
of actionDump: of actionDump:
options.action.projName = "" options.action.projName = ""
options.forcePrompts = forcePromptYes
of actionRefresh: of actionRefresh:
options.action.optionalURL = "" options.action.optionalURL = ""
of actionSearch: of actionSearch:
@ -264,8 +265,9 @@ proc parseArgument*(key: string, result: var Options) =
result.action.search.add(key) result.action.search.add(key)
of actionInit, actionDump: of actionInit, actionDump:
if result.action.projName != "": if result.action.projName != "":
raise newException(NimbleError, raise newException(
"Can only initialize one package at a time.") NimbleError, "Can only perform this action on one package at a time."
)
result.action.projName = key result.action.projName = key
of actionCompile, actionDoc: of actionCompile, actionDoc:
result.action.file = key result.action.file = key