summary refs log tree commit diff stats
path: root/nimpretty
diff options
context:
space:
mode:
authorMads Hougesen <madshougesen@gmail.com>2024-05-10 10:33:03 +0200
committerGitHub <noreply@github.com>2024-05-10 10:33:03 +0200
commitee59597cd4b1a275130a3e3017e279a59385ec28 (patch)
treec55f9f2e31e6755dcd8f962aff6da91a708fdbb0 /nimpretty
parent42486e1b2fe0d2e066c9f26e9f658cc03b843d44 (diff)
downloadNim-ee59597cd4b1a275130a3e3017e279a59385ec28.tar.gz
Add directory input support to nimpretty (#23590)
Feel free to close if this an unwanted addition :)
Diffstat (limited to 'nimpretty')
-rw-r--r--nimpretty/nimpretty.nim8
1 files changed, 7 insertions, 1 deletions
diff --git a/nimpretty/nimpretty.nim b/nimpretty/nimpretty.nim
index 8e8c58597..e5abf0d2d 100644
--- a/nimpretty/nimpretty.nim
+++ b/nimpretty/nimpretty.nim
@@ -116,7 +116,13 @@ proc main =
   for kind, key, val in getopt():
     case kind
     of cmdArgument:
-      infiles.add(key.addFileExt(".nim"))
+      if dirExists(key):
+        for file in walkDirRec(key, skipSpecial = true):
+          if file.endsWith(".nim") or file.endsWith(".nimble"):
+            infiles.add(file)
+      else:
+        infiles.add(key.addFileExt(".nim"))
+
     of cmdLongOption, cmdShortOption:
       case normalize(key)
       of "help", "h": writeHelp()