Fix --nimbledir for c command and separate flags into actions.
This commit is contained in:
parent
a04848060b
commit
cb1248a9b4
2 changed files with 51 additions and 31 deletions
|
|
@ -96,6 +96,10 @@ proc displayDebug*(category, msg: string) =
|
||||||
## Convenience for displaying debug messages.
|
## Convenience for displaying debug messages.
|
||||||
display(category, msg, priority = DebugPriority)
|
display(category, msg, priority = DebugPriority)
|
||||||
|
|
||||||
|
proc displayDebug*(msg: string) =
|
||||||
|
## Convenience for displaying debug messages with a default category.
|
||||||
|
displayDebug("Debug:", msg)
|
||||||
|
|
||||||
proc displayTip*() =
|
proc displayTip*() =
|
||||||
## Called just before Nimble exits. Shows some tips for the user, for example
|
## Called just before Nimble exits. Shows some tips for the user, for example
|
||||||
## the amount of messages that were suppressed and how to show them.
|
## the amount of messages that were suppressed and how to show them.
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ Usage: nimble COMMAND [opts]
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
install [pkgname, ...] Installs a list of packages.
|
install [pkgname, ...] Installs a list of packages.
|
||||||
|
[-d, --depsOnly] Install only dependencies.
|
||||||
init [pkgname] Initializes a new Nimble project.
|
init [pkgname] Initializes a new Nimble project.
|
||||||
publish Publishes a package on nim-lang/packages.
|
publish Publishes a package on nim-lang/packages.
|
||||||
The current working directory needs to be the
|
The current working directory needs to be the
|
||||||
|
|
@ -62,9 +63,11 @@ Commands:
|
||||||
to the Nim compiler.
|
to the Nim compiler.
|
||||||
refresh [url] Refreshes the package list. A package list URL
|
refresh [url] Refreshes the package list. A package list URL
|
||||||
can be optionally specified.
|
can be optionally specified.
|
||||||
search [--ver] pkg/tag Searches for a specified package. Search is
|
search pkg/tag Searches for a specified package. Search is
|
||||||
performed by tag and by name.
|
performed by tag and by name.
|
||||||
list [--ver] Lists all packages.
|
[--ver] Query remote server for package version.
|
||||||
|
list Lists all packages.
|
||||||
|
[--ver] Query remote server for package version.
|
||||||
[-i, --installed] Lists all installed packages.
|
[-i, --installed] Lists all installed packages.
|
||||||
tasks Lists the tasks specified in the Nimble
|
tasks Lists the tasks specified in the Nimble
|
||||||
package's Nimble file.
|
package's Nimble file.
|
||||||
|
|
@ -81,7 +84,6 @@ Options:
|
||||||
--ver Query remote server for package version
|
--ver Query remote server for package version
|
||||||
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.
|
|
||||||
--verbose Show all non-debug output.
|
--verbose Show all non-debug output.
|
||||||
--debug Show all output including debug messages.
|
--debug Show all output including debug messages.
|
||||||
|
|
||||||
|
|
@ -100,14 +102,10 @@ proc writeVersion() =
|
||||||
|
|
||||||
proc parseActionType*(action: string): ActionType =
|
proc parseActionType*(action: string): ActionType =
|
||||||
case action.normalize()
|
case action.normalize()
|
||||||
of "install", "path":
|
of "install":
|
||||||
case action.normalize()
|
result = actionInstall
|
||||||
of "install":
|
of "path":
|
||||||
result = actionInstall
|
result = actionPath
|
||||||
of "path":
|
|
||||||
result = actionPath
|
|
||||||
else:
|
|
||||||
discard
|
|
||||||
of "build":
|
of "build":
|
||||||
result = actionBuild
|
result = actionBuild
|
||||||
of "c", "compile", "js", "cpp", "cc":
|
of "c", "compile", "js", "cpp", "cc":
|
||||||
|
|
@ -230,29 +228,47 @@ proc parseArgument*(key: string, result: var Options) =
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc parseFlag*(flag, val: string, result: var Options) =
|
proc parseFlag*(flag, val: string, result: var Options) =
|
||||||
case result.action.typ
|
var wasFlagHandled = true
|
||||||
of actionCompile:
|
|
||||||
if val == "":
|
# Global flags.
|
||||||
result.action.compileOptions.add("--" & flag)
|
case flag.normalize()
|
||||||
|
of "help", "h": writeHelp()
|
||||||
|
of "version", "v": writeVersion()
|
||||||
|
of "accept", "y": result.forcePrompts = forcePromptYes
|
||||||
|
of "reject", "n": result.forcePrompts = forcePromptNo
|
||||||
|
of "nimbledir": result.nimbleDir = val
|
||||||
|
of "verbose": result.verbosity = LowPriority
|
||||||
|
of "debug": result.verbosity = DebugPriority
|
||||||
|
# Action-specific flags.
|
||||||
|
of "installed", "i":
|
||||||
|
if result.action.typ in [actionSearch, actionList]:
|
||||||
|
result.queryInstalled = true
|
||||||
else:
|
else:
|
||||||
result.action.compileOptions.add("--" & flag & ":" & val)
|
wasFlagHandled = false
|
||||||
of actionCustom:
|
of "depsonly", "d":
|
||||||
result.action.flags[flag] = val
|
if result.action.typ == actionInstall:
|
||||||
|
result.depsOnly = true
|
||||||
|
else:
|
||||||
|
wasFlagHandled = false
|
||||||
|
of "ver":
|
||||||
|
if result.action.typ in [actionSearch, actionList]:
|
||||||
|
result.queryVersions = true
|
||||||
|
else:
|
||||||
|
wasFlagHandled = false
|
||||||
else:
|
else:
|
||||||
# TODO: These should not be global.
|
case result.action.typ
|
||||||
case flag.normalize()
|
of actionCompile:
|
||||||
of "help", "h": writeHelp()
|
if val == "":
|
||||||
of "version", "v": writeVersion()
|
result.action.compileOptions.add("--" & flag)
|
||||||
of "accept", "y": result.forcePrompts = forcePromptYes
|
else:
|
||||||
of "reject", "n": result.forcePrompts = forcePromptNo
|
result.action.compileOptions.add("--" & flag & ":" & val)
|
||||||
of "ver": result.queryVersions = true
|
of actionCustom:
|
||||||
of "nimbledir": result.nimbleDir = val
|
result.action.flags[flag] = val
|
||||||
of "installed", "i": result.queryInstalled = true
|
|
||||||
of "depsonly", "d": result.depsOnly = true
|
|
||||||
of "verbose": result.verbosity = LowPriority
|
|
||||||
of "debug": result.verbosity = DebugPriority
|
|
||||||
else:
|
else:
|
||||||
raise newException(NimbleError, "Unknown option: --" & flag)
|
wasFlagHandled = false
|
||||||
|
|
||||||
|
if not wasFlagHandled:
|
||||||
|
raise newException(NimbleError, "Unknown option: --" & flag)
|
||||||
|
|
||||||
proc initOptions*(): Options =
|
proc initOptions*(): Options =
|
||||||
result.action.typ = actionNil
|
result.action.typ = actionNil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue