Merge branch 'pr_case_insensitive_search' of https://github.com/gradha/babel into gradha-pr_case_insensitive_search
Conflicts: babel.nim
This commit is contained in:
commit
2406776f89
2 changed files with 20 additions and 15 deletions
33
babel.nim
33
babel.nim
|
|
@ -352,31 +352,34 @@ proc build(options: TOptions) =
|
||||||
buildFromDir(pkgInfo, paths)
|
buildFromDir(pkgInfo, paths)
|
||||||
|
|
||||||
proc search(action: TAction) =
|
proc search(action: TAction) =
|
||||||
|
## Searches for matches in ``action.search``.
|
||||||
|
##
|
||||||
|
## Searches are done in a case insensitive way making all strings lower case.
|
||||||
|
## This requires the input search to already be lower case.
|
||||||
assert action.typ == ActionSearch
|
assert action.typ == ActionSearch
|
||||||
if action.search == @[]:
|
if action.search == @[]:
|
||||||
raise newException(EBabel, "Please specify a search string.")
|
raise newException(EBabel, "Please specify a search string.")
|
||||||
if not existsFile(babelDir / "packages.json"):
|
if not existsFile(babelDir / "packages.json"):
|
||||||
raise newException(EBabel, "Please run babel update.")
|
raise newException(EBabel, "Please run babel update.")
|
||||||
let pkgList = getPackageList(babelDir / "packages.json")
|
let pkgList = getPackageList(babelDir / "packages.json")
|
||||||
var found: seq[string] = @[]
|
var found = false
|
||||||
for pkg in pkgList:
|
template onFound: stmt =
|
||||||
for word in action.search:
|
echoPackage(pkg)
|
||||||
for tag in pkg.tags:
|
echo(" ")
|
||||||
if word in tag:
|
found = true
|
||||||
echoPackage(pkg)
|
break
|
||||||
echo(" ")
|
|
||||||
found.add(pkg.name)
|
|
||||||
break
|
|
||||||
|
|
||||||
# Search by name.
|
|
||||||
for pkg in pkgList:
|
for pkg in pkgList:
|
||||||
for word in action.search:
|
for word in action.search:
|
||||||
if word in pkg.name and pkg.name notin found:
|
# Search by name.
|
||||||
echoPackage(pkg)
|
if word.toLower() in pkg.name.toLower():
|
||||||
echo(" ")
|
onFound()
|
||||||
found.add(pkg.name)
|
# Search by tag.
|
||||||
|
for tag in pkg.tags:
|
||||||
|
if word.toLower() in tag.toLower():
|
||||||
|
onFound()
|
||||||
|
|
||||||
if found.len == 0:
|
if not found:
|
||||||
echo("No package found.")
|
echo("No package found.")
|
||||||
|
|
||||||
proc list =
|
proc list =
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,8 @@ substrings). Example:
|
||||||
description: Nimrod math library
|
description: Nimrod math library
|
||||||
license: MIT
|
license: MIT
|
||||||
|
|
||||||
|
Searches are performed ignoring case.
|
||||||
|
|
||||||
### babel path
|
### babel path
|
||||||
|
|
||||||
The babel ``path`` command will shows the absolute path to the installed
|
The babel ``path`` command will shows the absolute path to the installed
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue