Makes search case insensitive.
This commit is contained in:
parent
0e8c581e72
commit
1084b1553b
2 changed files with 10 additions and 3 deletions
11
babel.nim
11
babel.nim
|
|
@ -90,7 +90,7 @@ proc parseCmdLine(): TOptions =
|
||||||
of ActionUpdate:
|
of ActionUpdate:
|
||||||
result.action.optionalURL = key
|
result.action.optionalURL = key
|
||||||
of ActionSearch:
|
of ActionSearch:
|
||||||
result.action.search.add(key)
|
result.action.search.add(toLower(key))
|
||||||
of ActionList, ActionBuild:
|
of ActionList, ActionBuild:
|
||||||
writeHelp()
|
writeHelp()
|
||||||
of cmdLongOption, cmdShortOption:
|
of cmdLongOption, cmdShortOption:
|
||||||
|
|
@ -352,6 +352,10 @@ 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.")
|
||||||
|
|
@ -361,8 +365,9 @@ proc search(action: TAction) =
|
||||||
var notFound = true
|
var notFound = true
|
||||||
for pkg in pkgList:
|
for pkg in pkgList:
|
||||||
for word in action.search:
|
for word in action.search:
|
||||||
|
assert word == toLower(word)
|
||||||
for tag in pkg.tags:
|
for tag in pkg.tags:
|
||||||
if word in tag:
|
if word in toLower(tag):
|
||||||
echoPackage(pkg)
|
echoPackage(pkg)
|
||||||
echo(" ")
|
echo(" ")
|
||||||
notFound = false
|
notFound = false
|
||||||
|
|
@ -371,7 +376,7 @@ proc search(action: TAction) =
|
||||||
# Search by name.
|
# 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:
|
if word in toLower(pkg.name):
|
||||||
echoPackage(pkg)
|
echoPackage(pkg)
|
||||||
echo(" ")
|
echo(" ")
|
||||||
notFound = false
|
notFound = false
|
||||||
|
|
|
||||||
|
|
@ -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