fixes a 'break search loop' bug; got rid of most compiler warnings
This commit is contained in:
parent
a0670e9620
commit
ee3ad4353e
8 changed files with 30 additions and 34 deletions
|
|
@ -1,9 +1,11 @@
|
|||
# Copyright (C) Dominik Picheta. All rights reserved.
|
||||
# BSD License. Look at license.txt for more info.
|
||||
|
||||
import httpclient, parseopt, os, strutils, osproc, pegs, tables, parseutils,
|
||||
import httpclient, parseopt, os, osproc, pegs, tables, parseutils,
|
||||
strtabs, json, algorithm, sets, uri
|
||||
|
||||
import strutils except toLower
|
||||
from unicode import toLower
|
||||
from sequtils import toSeq
|
||||
|
||||
import nimblepkg/packageinfo, nimblepkg/version, nimblepkg/tools,
|
||||
|
|
@ -82,7 +84,7 @@ proc update(options: Options) =
|
|||
echo("Downloaded packages.json file is invalid, discarding.")
|
||||
continue
|
||||
copyFile(tempPath,
|
||||
options.getNimbleDir() / "packages_$1.json" % list.name.toLower())
|
||||
options.getNimbleDir() / "packages_$1.json" % list.name.toLowerAscii())
|
||||
echo("Done.")
|
||||
break
|
||||
|
||||
|
|
@ -609,7 +611,6 @@ proc compile(options: Options) =
|
|||
var pkgInfo = getPkgInfo(getCurrentDir(), options)
|
||||
nimScriptHint(pkgInfo)
|
||||
let paths = processDeps(pkginfo, options)
|
||||
let realDir = pkgInfo.getRealDir()
|
||||
|
||||
var args = ""
|
||||
for path in paths: args.add("--path:\"" & path & "\" ")
|
||||
|
|
@ -642,23 +643,24 @@ proc search(options: Options) =
|
|||
raise newException(NimbleError, "Please run nimble refresh.")
|
||||
let pkgList = getPackageList(options)
|
||||
var found = false
|
||||
template onFound: stmt =
|
||||
template onFound {.dirty.} =
|
||||
echoPackage(pkg)
|
||||
if options.queryVersions:
|
||||
echoPackageVersions(pkg)
|
||||
echo(" ")
|
||||
found = true
|
||||
break
|
||||
break forPkg
|
||||
|
||||
for pkg in pkgList:
|
||||
for word in options.action.search:
|
||||
# Search by name.
|
||||
if word.toLower() in pkg.name.toLower():
|
||||
onFound()
|
||||
# Search by tag.
|
||||
for tag in pkg.tags:
|
||||
if word.toLower() in tag.toLower():
|
||||
block forPkg:
|
||||
for word in options.action.search:
|
||||
# Search by name.
|
||||
if word.toLower() in pkg.name.toLower():
|
||||
onFound()
|
||||
# Search by tag.
|
||||
for tag in pkg.tags:
|
||||
if word.toLower() in tag.toLower():
|
||||
onFound()
|
||||
|
||||
if not found:
|
||||
echo("No package found.")
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ proc doDownload*(url: string, downloadDir: string, verRange: VersionRange,
|
|||
## method.
|
||||
##
|
||||
## Returns the version of the repository which has been downloaded.
|
||||
template getLatestByTag(meth: stmt): stmt {.dirty, immediate.} =
|
||||
template getLatestByTag(meth: untyped) {.dirty.} =
|
||||
echo("Found tags...")
|
||||
# Find latest version that fits our ``verRange``.
|
||||
var latest = findLatest(verRange, versions)
|
||||
|
|
|
|||
|
|
@ -94,10 +94,10 @@ proc setupVM(module: PSym; scriptName: string,
|
|||
|
||||
proc listDirs(a: VmArgs, filter: set[PathComponent]) =
|
||||
let dir = getString(a, 0)
|
||||
var result: seq[string] = @[]
|
||||
var res: seq[string] = @[]
|
||||
for kind, path in walkDir(dir):
|
||||
if kind in filter: result.add path
|
||||
setResult(a, result)
|
||||
if kind in filter: res.add path
|
||||
setResult(a, res)
|
||||
|
||||
template cbconf(name, body) {.dirty.} =
|
||||
result.registerCallback "stdlib.system." & astToStr(name),
|
||||
|
|
@ -346,7 +346,7 @@ proc readPackageInfoFromNims*(scriptName: string, options: Options,
|
|||
elif cmpIgnoreStyle(backend, "javascript") == 0:
|
||||
result.backend = "js"
|
||||
else:
|
||||
result.backend = backend.toLower()
|
||||
result.backend = backend.toLowerAscii()
|
||||
|
||||
# Grab all the global procs
|
||||
for i in thisModule.tab.data:
|
||||
|
|
@ -395,8 +395,8 @@ proc execHook*(scriptName, actionName: string, before: bool,
|
|||
result.flags = newStringTable()
|
||||
compiler_options.command = internalCmd
|
||||
let hookName =
|
||||
if before: actionName.toLower & "Before"
|
||||
else: actionName.toLower & "After"
|
||||
if before: actionName.toLowerAscii & "Before"
|
||||
else: actionName.toLowerAscii & "After"
|
||||
echo("Attempting to execute hook ", hookName, " in ", scriptName)
|
||||
|
||||
let thisModule = execScript(scriptName, result.flags, options)
|
||||
|
|
|
|||
|
|
@ -293,11 +293,6 @@ proc parseCmdLine*(): Options =
|
|||
if result.action.typ == actionNil:
|
||||
writeHelp()
|
||||
|
||||
# TODO: Remove this after a couple of versions.
|
||||
if getNimrodVersion() > newVersion("0.9.6"):
|
||||
# Rename deprecated babel dir.
|
||||
renameBabelToNimble(result)
|
||||
|
||||
proc getProxy*(options: Options): Proxy =
|
||||
## Returns ``nil`` if no proxy is specified.
|
||||
var url = ""
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ proc getPackage*(pkg: string, options: Options,
|
|||
for name, list in options.config.packageLists:
|
||||
echo("Searching in \"", name, "\" package list...")
|
||||
let packages = parseFile(options.getNimbleDir() /
|
||||
"packages_" & name.toLower() & ".json")
|
||||
"packages_" & name.toLowerAscii() & ".json")
|
||||
for p in packages:
|
||||
if normalize(p["name"].str) == normalize(pkg):
|
||||
resPkg = p.fromJson()
|
||||
|
|
@ -152,7 +152,7 @@ proc getPackageList*(options: Options): seq[Package] =
|
|||
var namesAdded = initSet[string]()
|
||||
for name, list in options.config.packageLists:
|
||||
let packages = parseFile(options.getNimbleDir() /
|
||||
"packages_" & name.toLower() & ".json")
|
||||
"packages_" & name.toLowerAscii() & ".json")
|
||||
for p in packages:
|
||||
let pkg: Package = p.fromJson()
|
||||
if pkg.name notin namesAdded:
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ import version, tools, common, nimscriptsupport, options, packageinfo
|
|||
## because it depends on ``nimscriptsupport`` (``nimscriptsupport`` also
|
||||
## depends on other procedures in ``packageinfo``.
|
||||
|
||||
when not declared(system.map):
|
||||
from sequtils import map
|
||||
from sequtils import apply
|
||||
|
||||
type
|
||||
NimbleFile* = string
|
||||
|
|
@ -105,7 +104,7 @@ proc multiSplit(s: string): seq[string] =
|
|||
## done no entries are found in the list, the proc returns a sequence with
|
||||
## the original string as the only entry.
|
||||
result = split(s, {char(0x0A), char(0x0D), ','})
|
||||
map(result, proc(x: var string) = x = x.strip())
|
||||
apply(result, proc(x: var string) = x = x.strip())
|
||||
for i in countdown(result.len()-1, 0):
|
||||
if len(result[i]) < 1:
|
||||
result.del(i)
|
||||
|
|
@ -154,7 +153,7 @@ proc readPackageInfoFromNimble(path: string; result: var PackageInfo) =
|
|||
for i in ev.value.multiSplit:
|
||||
result.bin.add(i.addFileExt(ExeExt))
|
||||
of "backend":
|
||||
result.backend = ev.value.toLower()
|
||||
result.backend = ev.value.toLowerAscii()
|
||||
case result.backend.normalize
|
||||
of "javascript": result.backend = "js"
|
||||
else: discard
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ proc doCmdEx*(cmd: string): tuple[output: TaintedString, exitCode: int] =
|
|||
raise newException(NimbleError, "'" & bin & "' not in PATH.")
|
||||
return execCmdEx(cmd)
|
||||
|
||||
template cd*(dir: string, body: stmt) =
|
||||
template cd*(dir: string, body: untyped) =
|
||||
## Sets the current dir to ``dir``, executes ``body`` and restores the
|
||||
## previous working dir.
|
||||
let lastDir = getCurrentDir()
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ proc newSpecial*(spe: string): Special = return Special(spe)
|
|||
|
||||
proc `$`*(ver: Version): string {.borrow.}
|
||||
|
||||
proc hash*(ver: Version): THash {.borrow.}
|
||||
proc hash*(ver: Version): Hash {.borrow.}
|
||||
|
||||
proc `$`*(ver: Special): string {.borrow.}
|
||||
|
||||
proc hash*(ver: Special): THash {.borrow.}
|
||||
proc hash*(ver: Special): Hash {.borrow.}
|
||||
|
||||
proc `<`*(ver: Version, ver2: Version): bool =
|
||||
var sVer = string(ver).split('.')
|
||||
|
|
@ -79,7 +79,7 @@ proc `==`*(ver: Version, ver2: Version): bool =
|
|||
return false
|
||||
|
||||
proc `==`*(spe: Special, spe2: Special): bool =
|
||||
return ($spe).toLower() == ($spe2).toLower()
|
||||
return ($spe).toLowerAscii() == ($spe2).toLowerAscii()
|
||||
|
||||
proc `<=`*(ver: Version, ver2: Version): bool =
|
||||
return (ver == ver2) or (ver < ver2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue