From fc56a53ced8c3102002f7acbb3e5fbc29bb0a96d Mon Sep 17 00:00:00 2001 From: Miroslav Shubernetskiy Date: Thu, 1 Feb 2024 12:36:38 -0500 Subject: [PATCH] recursively looking for files in newFileTable also normalizing name to lowercase so its easier to access keys in it as search can be normalized to lowecase chalk will be using that in upcoming PR related to the help system --- nimutils/filetable.nim | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/nimutils/filetable.nim b/nimutils/filetable.nim index d24637b..cbefdee 100644 --- a/nimutils/filetable.nim +++ b/nimutils/filetable.nim @@ -27,12 +27,15 @@ proc staticListFiles*(arg: string): seq[string] = result = @[] let - lines = staticExec("ls --color=never -pF " & arg & - " | grep -v \"[^a-zA-Z0-9]$\"") + lines = staticExec("find " & arg & " -type f " & + " | grep -v \"[^a-zA-Z0-9]$\"") items = split(lines, "\n") for item in items: - result.add(item.strip()) + var path = item + path.removePrefix(arg) + path.removePrefix(DirSep) + result.add(path.strip()) template newFileTable*(dir: static[string]): FileTable = @@ -55,7 +58,7 @@ template newFileTable*(dir: static[string]): FileTable = let pathToFile = pwd.joinPath(filename) fileContents = staticRead(pathToFile) - key = splitFile(filename).name + key = splitFile(filename).name.toLower() ret[key] = fileContents ret