Implement --verbosity switch.
This commit is contained in:
parent
8ebc4bb7c1
commit
2dab010c23
2 changed files with 10 additions and 1 deletions
|
|
@ -90,6 +90,8 @@ proc displayTip*() =
|
||||||
$globalCLI.suppressionCount
|
$globalCLI.suppressionCount
|
||||||
display("Tip", msg, Warning, HighPriority)
|
display("Tip", msg, Warning, HighPriority)
|
||||||
|
|
||||||
|
proc setVerbosity*(level: Priority) =
|
||||||
|
globalCLI.level = level
|
||||||
|
|
||||||
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",
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
import json, strutils, os, parseopt, strtabs, uri, tables
|
import json, strutils, os, parseopt, strtabs, uri, tables
|
||||||
from httpclient import Proxy, newProxy
|
from httpclient import Proxy, newProxy
|
||||||
|
|
||||||
import config, version, tools, common
|
import config, version, tools, common, cli
|
||||||
|
|
||||||
type
|
type
|
||||||
Options* = object
|
Options* = object
|
||||||
|
|
@ -13,6 +13,7 @@ type
|
||||||
queryVersions*: bool
|
queryVersions*: bool
|
||||||
queryInstalled*: bool
|
queryInstalled*: bool
|
||||||
nimbleDir*: string
|
nimbleDir*: string
|
||||||
|
verbosity*: cli.Priority
|
||||||
action*: Action
|
action*: Action
|
||||||
config*: Config
|
config*: Config
|
||||||
nimbleData*: JsonNode ## Nimbledata.json
|
nimbleData*: JsonNode ## Nimbledata.json
|
||||||
|
|
@ -84,6 +85,7 @@ Options:
|
||||||
information when searching or listing packages
|
information when searching or listing packages
|
||||||
--nimbleDir dirname Set the Nimble directory.
|
--nimbleDir dirname Set the Nimble directory.
|
||||||
-d --depsOnly Install only dependencies.
|
-d --depsOnly Install only dependencies.
|
||||||
|
--verbose Show all output.
|
||||||
|
|
||||||
For more information read the Github readme:
|
For more information read the Github readme:
|
||||||
https://github.com/nim-lang/nimble#readme
|
https://github.com/nim-lang/nimble#readme
|
||||||
|
|
@ -265,6 +267,7 @@ proc parseFlag*(flag, val: string, result: var Options) =
|
||||||
of "nimbledir": result.nimbleDir = val
|
of "nimbledir": result.nimbleDir = val
|
||||||
of "installed", "i": result.queryInstalled = true
|
of "installed", "i": result.queryInstalled = true
|
||||||
of "depsonly", "d": result.depsOnly = true
|
of "depsonly", "d": result.depsOnly = true
|
||||||
|
of "verbose": result.verbosity = LowPriority
|
||||||
else:
|
else:
|
||||||
raise newException(NimbleError, "Unknown option: --" & flag)
|
raise newException(NimbleError, "Unknown option: --" & flag)
|
||||||
|
|
||||||
|
|
@ -272,6 +275,7 @@ proc initOptions*(): Options =
|
||||||
result.action.typ = actionNil
|
result.action.typ = actionNil
|
||||||
result.pkgInfoCache = newTable[string, PackageInfo]()
|
result.pkgInfoCache = newTable[string, PackageInfo]()
|
||||||
result.nimbleDir = ""
|
result.nimbleDir = ""
|
||||||
|
result.verbosity = HighPriority
|
||||||
|
|
||||||
proc parseMisc(options: var Options) =
|
proc parseMisc(options: var Options) =
|
||||||
# Load nimbledata.json
|
# Load nimbledata.json
|
||||||
|
|
@ -302,6 +306,9 @@ proc parseCmdLine*(): Options =
|
||||||
parseFlag(key, val, result)
|
parseFlag(key, val, result)
|
||||||
of cmdEnd: assert(false) # cannot happen
|
of cmdEnd: assert(false) # cannot happen
|
||||||
|
|
||||||
|
# Set verbosity level.
|
||||||
|
setVerbosity(result.verbosity)
|
||||||
|
|
||||||
# Parse config.
|
# Parse config.
|
||||||
result.config = parseConfig()
|
result.config = parseConfig()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue