Rename 'opt' back to 'options'.

This commit is contained in:
Dominik Picheta 2015-11-07 16:15:47 +00:00
commit 26f5fcdd3f

View file

@ -10,7 +10,7 @@ import nimblepkg/packageinfo, nimblepkg/version, nimblepkg/tools,
nimblepkg/download, nimblepkg/config, nimblepkg/nimbletypes,
nimblepkg/publish
import compiler/options
import compiler/options as compiler_options
when not defined(windows):
from posix import getpid
@ -117,21 +117,21 @@ proc writeVersion() =
[nimbleVersion, CompileDate, CompileTime])
quit(QuitSuccess)
proc getNimbleDir(opt: Options): string =
opt.config.nimbleDir
proc getNimbleDir(options: Options): string =
options.config.nimbleDir
proc getPkgsDir(opt: Options): string =
opt.config.nimbleDir / "pkgs"
proc getPkgsDir(options: Options): string =
options.config.nimbleDir / "pkgs"
proc getBinDir(opt: Options): string =
opt.config.nimbleDir / "bin"
proc getBinDir(options: Options): string =
options.config.nimbleDir / "bin"
proc prompt(opt: Options, question: string): bool =
proc prompt(options: Options, question: string): bool =
## Asks an interactive question and returns the result.
##
## The proc will return immediately without asking the user if the global
## forcePrompts has a value different than dontForcePrompt.
case opt.forcePrompts
case options.forcePrompts
of forcePromptYes:
echo(question & " -> [forced yes]")
return true
@ -149,11 +149,11 @@ proc prompt(opt: Options, question: string): bool =
else:
return false
proc renameBabelToNimble(opt: Options) {.deprecated.} =
proc renameBabelToNimble(options: Options) {.deprecated.} =
let babelDir = getHomeDir() / ".babel"
let nimbleDir = getHomeDir() / ".nimble"
if dirExists(babelDir):
if opt.prompt("Found deprecated babel package directory, would you " &
if options.prompt("Found deprecated babel package directory, would you " &
"like to rename it to nimble?"):
copyDir(babelDir, nimbleDir)
copyFile(babelDir / "babeldata.json", nimbleDir / "nimbledata.json")
@ -168,7 +168,7 @@ proc parseCmdLine(): Options =
case kind
of cmdArgument:
if result.action.typ == actionNil:
options.command = key
compiler_options.command = key
case key.normalize()
of "install", "path":
case key.normalize()
@ -274,18 +274,18 @@ proc parseCmdLine(): Options =
else:
result.nimbleData = %{"reverseDeps": newJObject()}
proc update(opt: Options) =
proc update(options: Options) =
## Downloads the package list from the specified URL.
##
## If the download is successful, the global didUpdatePackages is set to
## true. Otherwise an exception is raised on error.
let url =
if opt.action.typ == actionUpdate and opt.action.optionalURL != "":
opt.action.optionalURL
if options.action.typ == actionUpdate and options.action.optionalURL != "":
options.action.optionalURL
else:
defaultPackageURL
echo("Downloading package list from " & url)
downloadFile(url, opt.getNimbleDir() / "packages.json")
downloadFile(url, options.getNimbleDir() / "packages.json")
echo("Done.")
proc checkInstallFile(pkgInfo: PackageInfo,
@ -336,7 +336,7 @@ proc copyWithExt(origDir, currentDir, dest: string,
result.add copyFileD(path, changeRoot(origDir, dest, path))
proc copyFilesRec(origDir, currentDir, dest: string,
opt: Options, pkgInfo: PackageInfo): HashSet[string] =
options: Options, pkgInfo: PackageInfo): HashSet[string] =
## Copies all the required files, skips files specified in the .nimble file
## (PackageInfo).
## Returns a list of filepaths to files which have been installed.
@ -349,7 +349,7 @@ proc copyFilesRec(origDir, currentDir, dest: string,
for file in pkgInfo.installFiles:
let src = origDir / file
if not src.existsFile():
if opt.prompt("Missing file " & src & ". Continue?"):
if options.prompt("Missing file " & src & ". Continue?"):
continue
else:
quit(QuitSuccess)
@ -360,7 +360,7 @@ proc copyFilesRec(origDir, currentDir, dest: string,
# TODO: Allow skipping files inside dirs?
let src = origDir / dir
if not src.existsDir():
if opt.prompt("Missing directory " & src & ". Continue?"):
if options.prompt("Missing directory " & src & ". Continue?"):
continue
else:
quit(QuitSuccess)
@ -376,7 +376,7 @@ proc copyFilesRec(origDir, currentDir, dest: string,
# Create the dir.
createDir(changeRoot(origDir, dest, file))
result.incl copyFilesRec(origDir, file, dest, opt, pkgInfo)
result.incl copyFilesRec(origDir, file, dest, options, pkgInfo)
else:
let skip = pkgInfo.checkInstallFile(origDir, file)
@ -387,26 +387,26 @@ proc copyFilesRec(origDir, currentDir, dest: string,
result.incl copyFileD(pkgInfo.mypath,
changeRoot(pkgInfo.mypath.splitFile.dir, dest, pkgInfo.mypath))
proc saveNimbleData(opt: Options) =
proc saveNimbleData(options: Options) =
# TODO: This file should probably be locked.
writeFile(opt.getNimbleDir() / "nimbledata.json",
pretty(opt.nimbleData))
writeFile(options.getNimbleDir() / "nimbledata.json",
pretty(options.nimbleData))
proc addRevDep(opt: Options, dep: tuple[name, version: string],
proc addRevDep(options: Options, dep: tuple[name, version: string],
pkg: PackageInfo) =
# let depNameVer = dep.name & '-' & dep.version
if not opt.nimbleData["reverseDeps"].hasKey(dep.name):
opt.nimbleData["reverseDeps"][dep.name] = newJObject()
if not opt.nimbleData["reverseDeps"][dep.name].hasKey(dep.version):
opt.nimbleData["reverseDeps"][dep.name][dep.version] = newJArray()
if not options.nimbleData["reverseDeps"].hasKey(dep.name):
options.nimbleData["reverseDeps"][dep.name] = newJObject()
if not options.nimbleData["reverseDeps"][dep.name].hasKey(dep.version):
options.nimbleData["reverseDeps"][dep.name][dep.version] = newJArray()
let revDep = %{ "name": %pkg.name, "version": %pkg.version}
let thisDep = opt.nimbleData["reverseDeps"][dep.name][dep.version]
let thisDep = options.nimbleData["reverseDeps"][dep.name][dep.version]
if revDep notin thisDep:
thisDep.add revDep
proc removeRevDep(opt: Options, pkg: PackageInfo) =
proc removeRevDep(options: Options, pkg: PackageInfo) =
## Removes ``pkg`` from the reverse dependencies of every package.
proc remove(opt: Options, pkg: PackageInfo, depTup: PkgTuple,
proc remove(options: Options, pkg: PackageInfo, depTup: PkgTuple,
thisDep: JsonNode) =
for ver, val in thisDep:
if ver.newVersion in depTup.ver:
@ -420,16 +420,16 @@ proc removeRevDep(opt: Options, pkg: PackageInfo) =
for depTup in pkg.requires:
if depTup.name.isURL():
# We sadly must go through everything in this case...
for key, val in opt.nimbleData["reverseDeps"]:
opt.remove(pkg, depTup, val)
for key, val in options.nimbleData["reverseDeps"]:
options.remove(pkg, depTup, val)
else:
let thisDep = opt.nimbleData["reverseDeps"][depTup.name]
let thisDep = options.nimbleData["reverseDeps"][depTup.name]
if thisDep.isNil: continue
opt.remove(pkg, depTup, thisDep)
options.remove(pkg, depTup, thisDep)
# Clean up empty objects/arrays
var newData = newJObject()
for key, val in opt.nimbleData["reverseDeps"]:
for key, val in options.nimbleData["reverseDeps"]:
if val.len != 0:
var newVal = newJObject()
for ver, elem in val:
@ -437,19 +437,19 @@ proc removeRevDep(opt: Options, pkg: PackageInfo) =
newVal[ver] = elem
if newVal.len != 0:
newData[key] = newVal
opt.nimbleData["reverseDeps"] = newData
options.nimbleData["reverseDeps"] = newData
saveNimbleData(opt)
saveNimbleData(options)
proc install(packages: seq[PkgTuple],
opt: Options,
options: Options,
doPrompt = true): tuple[paths: seq[string], pkg: PackageInfo]
proc processDeps(pkginfo: PackageInfo, opt: Options): seq[string] =
proc processDeps(pkginfo: PackageInfo, options: Options): seq[string] =
## Verifies and installs dependencies.
##
## Returns the list of paths to pass to the compiler during build phase.
result = @[]
let pkglist = getInstalledPkgs(opt.getPkgsDir())
let pkglist = getInstalledPkgs(options.getPkgsDir())
var reverseDeps: seq[tuple[name, version: string]] = @[]
for dep in pkginfo.requires:
if dep.name == "nimrod" or dep.name == "nim":
@ -461,7 +461,7 @@ proc processDeps(pkginfo: PackageInfo, opt: Options): seq[string] =
var pkg: PackageInfo
if not findPkg(pkglist, dep, pkg):
echo("None found, installing...")
let (paths, installedPkg) = install(@[(dep.name, dep.ver)], opt)
let (paths, installedPkg) = install(@[(dep.name, dep.ver)], options)
result.add(paths)
pkg = installedPkg # For addRevDep
@ -469,7 +469,7 @@ proc processDeps(pkginfo: PackageInfo, opt: Options): seq[string] =
echo("Dependency already satisfied.")
result.add(pkg.mypath.splitFile.dir)
# Process the dependencies of this dependency.
result.add(processDeps(pkg, opt))
result.add(processDeps(pkg, options))
reverseDeps.add((pkg.name, pkg.version))
# Check if two packages of the same name (but different version) are listed
@ -487,8 +487,8 @@ proc processDeps(pkginfo: PackageInfo, opt: Options): seq[string] =
# them added if the above errorenous condition occurs
# (unsatisfiable dependendencies).
for i in reverseDeps:
addRevDep(opt, i, pkginfo)
saveNimbleData(opt)
addRevDep(options, i, pkginfo)
saveNimbleData(options)
proc buildFromDir(pkgInfo: PackageInfo, paths: seq[string], forRelease: bool) =
## Builds a package as specified by ``pkgInfo``.
@ -515,7 +515,7 @@ proc saveNimbleMeta(pkgDestDir, url: string, filesInstalled: HashSet[string]) =
nimblemeta["files"].add(%changeRoot(pkgDestDir, "", file))
writeFile(pkgDestDir / "nimblemeta.json", $nimblemeta)
proc removePkgDir(dir: string, opt: Options) =
proc removePkgDir(dir: string, options: Options) =
## Removes files belonging to the package in ``dir``.
try:
var nimblemeta = parseFile(dir / "nimblemeta.json")
@ -535,12 +535,12 @@ proc removePkgDir(dir: string, opt: Options) =
". Files not installed by nimble are present.")
except OSError, JsonParsingError:
echo("Error: Unable to read nimblemeta.json: ", getCurrentExceptionMsg())
if not opt.prompt("Would you like to COMPLETELY remove ALL files " &
if not options.prompt("Would you like to COMPLETELY remove ALL files " &
"in " & dir & "?"):
quit(QuitSuccess)
removeDir(dir)
proc installFromDir(dir: string, latest: bool, opt: Options,
proc installFromDir(dir: string, latest: bool, options: Options,
url: string): tuple[paths: seq[string], pkg: PackageInfo] =
## Returns where package has been installed to, together with paths
## to the packages this package depends on.
@ -548,10 +548,10 @@ proc installFromDir(dir: string, latest: bool, opt: Options,
## ``processDeps`` to gather a list of paths to pass to the nim compiler.
var pkgInfo = getPkgInfo(dir)
let realDir = pkgInfo.getRealDir()
let binDir = opt.getBinDir()
let pkgsDir = opt.getPkgsDir()
let binDir = options.getBinDir()
let pkgsDir = options.getPkgsDir()
# Dependencies need to be processed before the creation of the pkg dir.
result.paths = processDeps(pkginfo, opt)
result.paths = processDeps(pkginfo, options)
echo("Installing ", pkginfo.name, "-", pkginfo.version)
@ -562,10 +562,10 @@ proc installFromDir(dir: string, latest: bool, opt: Options,
let versionStr = (if latest: "" else: '-' & pkgInfo.version)
let pkgDestDir = pkgsDir / (pkgInfo.name & versionStr)
if existsDir(pkgDestDir) and existsFile(pkgDestDir / "nimblemeta.json"):
if not opt.prompt(pkgInfo.name & versionStr &
if not options.prompt(pkgInfo.name & versionStr &
" already exists. Overwrite?"):
quit(QuitSuccess)
removePkgDir(pkgDestDir, opt)
removePkgDir(pkgDestDir, options)
# Remove any symlinked binaries
for bin in pkgInfo.bin:
# TODO: Check that this binary belongs to the package being installed.
@ -585,7 +585,7 @@ proc installFromDir(dir: string, latest: bool, opt: Options,
if pkgInfo.bin.len > 0:
createDir(binDir)
# Copy all binaries and files that are not skipped
filesInstalled = copyFilesRec(realDir, realDir, pkgDestDir, opt,
filesInstalled = copyFilesRec(realDir, realDir, pkgDestDir, options,
pkgInfo)
# Set file permissions to +x for all binaries built,
# and symlink them on *nix OS' to $nimbleDir/bin/
@ -617,7 +617,7 @@ proc installFromDir(dir: string, latest: bool, opt: Options,
let dest = binDir / cleanBin.changeFileExt("cmd")
echo("Creating stub: ", pkgDestDir / bin, " -> ", dest)
var contents = "@"
if opt.config.chcp:
if options.config.chcp:
if fixChcp:
contents.add "chcp 65001 > nul && "
else: contents.add "chcp 65001 > nul\n@"
@ -630,7 +630,7 @@ proc installFromDir(dir: string, latest: bool, opt: Options,
else:
{.error: "Sorry, your platform is not supported.".}
else:
filesInstalled = copyFilesRec(realDir, realDir, pkgDestDir, opt,
filesInstalled = copyFilesRec(realDir, realDir, pkgDestDir, options,
pkgInfo)
# Save a nimblemeta.json file.
@ -669,46 +669,46 @@ proc downloadPkg(url: string, verRange: VersionRange,
echo("Downloading ", url, " into ", downloadDir, " using ", downMethod, "...")
result = (downloadDir, doDownload(url, downloadDir, verRange, downMethod))
proc getDownloadInfo*(pv: PkgTuple, opt: Options,
proc getDownloadInfo*(pv: PkgTuple, options: Options,
doPrompt: bool): (DownloadMethod, string) =
if pv.name.isURL:
return (checkUrlType(pv.name), pv.name)
else:
var pkg: Package
if getPackage(pv.name, opt.getNimbleDir() / "packages.json", pkg):
if getPackage(pv.name, options.getNimbleDir() / "packages.json", pkg):
return (pkg.downloadMethod.getDownloadMethod(), pkg.url)
else:
# If package is not found give the user a chance to update
# package.json
if doPrompt and
opt.prompt(pv.name & " not found in local packages.json, " &
options.prompt(pv.name & " not found in local packages.json, " &
"check internet for updated packages?"):
update(opt)
return getDownloadInfo(pv, opt, doPrompt)
update(options)
return getDownloadInfo(pv, options, doPrompt)
else:
raise newException(NimbleError, "Package not found.")
proc install(packages: seq[PkgTuple],
opt: Options,
options: Options,
doPrompt = true): tuple[paths: seq[string], pkg: PackageInfo] =
if packages == @[]:
result = installFromDir(getCurrentDir(), false, opt, "")
result = installFromDir(getCurrentDir(), false, options, "")
else:
# If packages.json is not present ask the user if they want to download it.
if not existsFile(opt.getNimbleDir / "packages.json"):
if not existsFile(options.getNimbleDir / "packages.json"):
if doPrompt and
opt.prompt("Local packages.json not found, download it from " &
options.prompt("Local packages.json not found, download it from " &
"internet?"):
update(opt)
update(options)
else:
quit("Please run nimble update.", QuitFailure)
# Install each package.
for pv in packages:
let (meth, url) = getDownloadInfo(pv, opt, doPrompt)
let (meth, url) = getDownloadInfo(pv, options, doPrompt)
let (downloadDir, downloadVersion) = downloadPkg(url, pv.ver, meth)
try:
result = installFromDir(downloadDir, false, opt, url)
result = installFromDir(downloadDir, false, options, url)
except BuildFailed:
# The package failed to build.
# Check if we tried building a tagged version of the package.
@ -717,37 +717,37 @@ proc install(packages: seq[PkgTuple],
# If we tried building a tagged version of the package then
# ask the user whether they want to try building #head.
let promptResult = doPrompt and
opt.prompt(("Build failed for '$1@$2', would you" &
options.prompt(("Build failed for '$1@$2', would you" &
" like to try installing '$1@#head' (latest unstable)?") %
[pv.name, $downloadVersion])
if promptResult:
result = install(@[(pv.name, headVer)], opt, doPrompt)
result = install(@[(pv.name, headVer)], options, doPrompt)
else:
raise newException(BuildFailed,
"Aborting installation due to build failure")
else:
raise
proc build(opt: Options) =
proc build(options: Options) =
var pkgInfo = getPkgInfo(getCurrentDir())
let paths = processDeps(pkginfo, opt)
let paths = processDeps(pkginfo, options)
buildFromDir(pkgInfo, paths, false)
proc compile(opt: Options) =
proc compile(options: Options) =
var pkgInfo = getPkgInfo(getCurrentDir())
let paths = processDeps(pkginfo, opt)
let paths = processDeps(pkginfo, options)
let realDir = pkgInfo.getRealDir()
var args = ""
for path in paths: args.add("--path:\"" & path & "\" ")
for option in opt.action.compileOptions:
for option in options.action.compileOptions:
args.add(option & " ")
let bin = opt.action.file
let bin = options.action.file
let backend =
if opt.action.backend.len > 0:
opt.action.backend
if options.action.backend.len > 0:
options.action.backend
else:
pkgInfo.backend
@ -759,27 +759,27 @@ proc compile(opt: Options) =
doCmd(getNimBin() & " $# --noBabelPath $# \"$#\"" %
[backend, args, bin])
proc search(opt: Options) =
## Searches for matches in ``opt.action.search``.
proc search(options: Options) =
## Searches for matches in ``options.action.search``.
##
## Searches are done in a case insensitive way making all strings lower case.
assert opt.action.typ == actionSearch
if opt.action.search == @[]:
assert options.action.typ == actionSearch
if options.action.search == @[]:
raise newException(NimbleError, "Please specify a search string.")
if not existsFile(opt.getNimbleDir() / "packages.json"):
if not existsFile(options.getNimbleDir() / "packages.json"):
raise newException(NimbleError, "Please run nimble update.")
let pkgList = getPackageList(opt.getNimbleDir() / "packages.json")
let pkgList = getPackageList(options.getNimbleDir() / "packages.json")
var found = false
template onFound: stmt =
echoPackage(pkg)
if opt.queryVersions:
if options.queryVersions:
echoPackageVersions(pkg)
echo(" ")
found = true
break
for pkg in pkgList:
for word in opt.action.search:
for word in options.action.search:
# Search by name.
if word.toLower() in pkg.name.toLower():
onFound()
@ -791,19 +791,19 @@ proc search(opt: Options) =
if not found:
echo("No package found.")
proc list(opt: Options) =
if not existsFile(opt.getNimbleDir() / "packages.json"):
proc list(options: Options) =
if not existsFile(options.getNimbleDir() / "packages.json"):
raise newException(NimbleError, "Please run nimble update.")
let pkgList = getPackageList(opt.getNimbleDir() / "packages.json")
let pkgList = getPackageList(options.getNimbleDir() / "packages.json")
for pkg in pkgList:
echoPackage(pkg)
if opt.queryVersions:
if options.queryVersions:
echoPackageVersions(pkg)
echo(" ")
proc listInstalled(opt: Options) =
proc listInstalled(options: Options) =
var h = initTable[string, seq[string]]()
let pkgs = getInstalledPkgs(opt.getPkgsDir())
let pkgs = getInstalledPkgs(options.getPkgsDir())
for x in pkgs.items():
let
pName = x.pkginfo.name
@ -817,7 +817,7 @@ proc listInstalled(opt: Options) =
type VersionAndPath = tuple[version: Version, path: string]
proc listPaths(opt: Options) =
proc listPaths(options: Options) =
## Loops over installing packages displaying their installed paths.
##
## If there are several packages installed, only the last one (the version
@ -826,14 +826,14 @@ proc listPaths(opt: Options) =
## but at the end quits with a non zero exit error.
##
## On success the proc returns normally.
assert opt.action.typ == actionPath
assert(not opt.action.packages.isNil)
assert options.action.typ == actionPath
assert(not options.action.packages.isNil)
var errors = 0
for name, version in opt.action.packages.items:
for name, version in options.action.packages.items:
var installed: seq[VersionAndPath] = @[]
# There may be several, list all available ones and sort by version.
for kind, path in walkDir(opt.getPkgsDir):
if kind != pcDir or not path.startsWith(opt.getPkgsDir / name):
for kind, path in walkDir(options.getPkgsDir):
if kind != pcDir or not path.startsWith(options.getPkgsDir / name):
continue
let
@ -846,7 +846,7 @@ proc listPaths(opt: Options) =
var pkgInfo = getPkgInfo(path)
var v: VersionAndPath
v.version = newVersion(pkgInfo.version)
v.path = opt.getPkgsDir / (pkgInfo.name & '-' & pkgInfo.version)
v.path = options.getPkgsDir / (pkgInfo.name & '-' & pkgInfo.version)
installed.add(v)
else:
echo "Warning: No .nimble file found for ", path
@ -874,8 +874,8 @@ proc join(x: seq[PkgTuple]; y: string): string =
result.add y
result.add x[i][0] & " " & $x[i][1]
proc dump(opt: Options) =
let proj = addFileExt(opt.action.projName, NimsExt)
proc dump(options: Options) =
let proj = addFileExt(options.action.projName, NimsExt)
let p = if fileExists(proj): readPackageInfo((true, proj))
else: getPkgInfo(os.getCurrentDir())
echo "name: ", p.name.escape
@ -895,14 +895,14 @@ proc dump(opt: Options) =
echo "srcDir: ", p.srcDir.escape
echo "backend: ", p.backend.escape
proc init(opt: Options) =
proc init(options: Options) =
echo("Initializing new Nimble project!")
var
pkgName, fName: string = ""
outFile: File
if opt.action.projName != "":
pkgName = opt.action.projName
if options.action.projName != "":
pkgName = options.action.projName
fName = pkgName & NimsExt
if (existsFile(os.getCurrentDir() / fName)):
raise newException(NimbleError, "Already have a nimscript file.")
@ -936,16 +936,16 @@ requires "nim >= "0.11.2"
raise newException(NimbleError, "Unable to open file " & fName &
" for writing: " & osErrorMsg(osLastError()))
proc uninstall(opt: Options) =
if opt.action.packages.len == 0:
proc uninstall(options: Options) =
if options.action.packages.len == 0:
raise newException(NimbleError,
"Please specify the package(s) to uninstall.")
var pkgsToDelete: seq[PackageInfo] = @[]
# Do some verification.
for pkgTup in opt.action.packages:
for pkgTup in options.action.packages:
echo("Looking for ", pkgTup.name, " (", $pkgTup.ver, ")...")
let installedPkgs = getInstalledPkgs(opt.getPkgsDir())
let installedPkgs = getInstalledPkgs(options.getPkgsDir())
var pkgList = findAllPkgs(installedPkgs, pkgTup)
if pkgList.len == 0:
raise newException(NimbleError, "Package not found")
@ -955,7 +955,7 @@ proc uninstall(opt: Options) =
for pkg in pkgList:
# Check whether any packages depend on the ones the user is trying to
# uninstall.
let thisPkgsDep = opt.nimbleData["reverseDeps"]{pkg.name}{pkg.version}
let thisPkgsDep = options.nimbleData["reverseDeps"]{pkg.name}{pkg.version}
if not thisPkgsDep.isNil:
var reason = ""
if thisPkgsDep.len == 1:
@ -983,49 +983,49 @@ proc uninstall(opt: Options) =
pkgNames.add pkg.name & " (" & pkg.version & ")"
# Let's confirm that the user wants these packages removed.
if not opt.prompt("The following packages will be removed:\n " &
if not options.prompt("The following packages will be removed:\n " &
pkgNames & "\nDo you wish to continue?"):
quit(QuitSuccess)
for pkg in pkgsToDelete:
# If we reach this point then the package can be safely removed.
removeRevDep(opt, pkg)
removePkgDir(opt.getPkgsDir / (pkg.name & '-' & pkg.version), opt)
removeRevDep(options, pkg)
removePkgDir(options.getPkgsDir / (pkg.name & '-' & pkg.version), options)
echo("Removed ", pkg.name, " (", $pkg.version, ")")
proc getCommand: string = options.command
proc getCommand: string = compiler_options.command
proc doAction(opt: Options) =
if not existsDir(opt.getNimbleDir()):
createDir(opt.getNimbleDir())
if not existsDir(opt.getPkgsDir):
createDir(opt.getPkgsDir)
proc doAction(options: Options) =
if not existsDir(options.getNimbleDir()):
createDir(options.getNimbleDir())
if not existsDir(options.getPkgsDir):
createDir(options.getPkgsDir)
case getCommand().normalize
of "udpate":
update(opt)
update(options)
of "install":
discard install(opt.action.packages, opt)
discard install(options.action.packages, options)
of "uninstall", "remove", "delete", "del", "rm":
uninstall(opt)
uninstall(options)
of "search":
search(opt)
search(options)
of "list":
if opt.queryInstalled: listInstalled(opt)
else: list(opt)
if options.queryInstalled: listInstalled(options)
else: list(options)
of "path":
listPaths(opt)
listPaths(options)
of "build":
build(opt)
build(options)
of "c", "compile", "js", "cpp", "cc":
compile(opt)
compile(options)
of "init":
init(opt)
init(options)
of "publish":
var pkgInfo = getPkgInfo(getCurrentDir())
publish(pkgInfo)
of "dump":
dump(opt)
dump(options)
of "nop": discard
else:
raise newException(NimbleError, "Unknown command: " & getCommand())