From 1084b1553bee04256f87bf55893e57021e2e1679 Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Mon, 9 Dec 2013 10:15:03 +0100 Subject: [PATCH] Makes search case insensitive. --- babel.nim | 11 ++++++++--- readme.markdown | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/babel.nim b/babel.nim index b9138fe..0a250f2 100644 --- a/babel.nim +++ b/babel.nim @@ -90,7 +90,7 @@ proc parseCmdLine(): TOptions = of ActionUpdate: result.action.optionalURL = key of ActionSearch: - result.action.search.add(key) + result.action.search.add(toLower(key)) of ActionList, ActionBuild: writeHelp() of cmdLongOption, cmdShortOption: @@ -352,6 +352,10 @@ proc build(options: TOptions) = buildFromDir(pkgInfo, paths) 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 if action.search == @[]: raise newException(EBabel, "Please specify a search string.") @@ -361,8 +365,9 @@ proc search(action: TAction) = var notFound = true for pkg in pkgList: for word in action.search: + assert word == toLower(word) for tag in pkg.tags: - if word in tag: + if word in toLower(tag): echoPackage(pkg) echo(" ") notFound = false @@ -371,7 +376,7 @@ proc search(action: TAction) = # Search by name. for pkg in pkgList: for word in action.search: - if word in pkg.name: + if word in toLower(pkg.name): echoPackage(pkg) echo(" ") notFound = false diff --git a/readme.markdown b/readme.markdown index c047c45..0b92e2e 100644 --- a/readme.markdown +++ b/readme.markdown @@ -103,6 +103,8 @@ substrings). Example: description: Nimrod math library license: MIT +Searches are performed ignoring case. + ### babel path The babel ``path`` command will shows the absolute path to the installed