summaryrefslogtreecommitdiff
path: root/short.nimble
diff options
context:
space:
mode:
authorJulien Dessaux2021-10-26 21:41:39 +0200
committerJulien Dessaux2021-10-26 21:41:39 +0200
commit7f79a49bff7883db126481f8c8a795aa312e3505 (patch)
treef04efeff6440f580a9f109686e1cb30822c40ad6 /short.nimble
parentAdded 6 months expiration option (diff)
downloadshort-7f79a49bff7883db126481f8c8a795aa312e3505.tar.gz
short-7f79a49bff7883db126481f8c8a795aa312e3505.tar.bz2
short-7f79a49bff7883db126481f8c8a795aa312e3505.zip
cosmetics
Diffstat (limited to '')
-rw-r--r--short.nimble17
1 files changed, 17 insertions, 0 deletions
diff --git a/short.nimble b/short.nimble
index 5da3330..ab89b75 100644
--- a/short.nimble
+++ b/short.nimble
@@ -14,3 +14,20 @@ requires "nim >= 1.4.8",
"https://github.com/dom96/jester#HEAD",
"nimja >= 0.4.1",
"https://github.com/GULPF/tiny_sqlite#HEAD"
+
+import os, strformat
+
+task fmt, "Run nimpretty on all git-managed .nim files in the current repo":
+ ## Usage: nim fmt
+ for file in walkDirRec("./", {pcFile, pcDir}):
+ if file.splitFile().ext == ".nim":
+ let
+ # https://github.com/nim-lang/Nim/issues/6262#issuecomment-454983572
+ # https://stackoverflow.com/a/2406813/1219634
+ fileIsGitManaged = gorgeEx("cd $1 && git ls-files --error-unmatch $2" % [getCurrentDir(), file]).exitCode == 0
+ # ^^^^^-- That "cd" is required.
+ if fileIsGitManaged:
+ let
+ cmd = "nimpretty --maxLineLen=220 $1" % [file]
+ echo "Running $1 .." % [cmd]
+ exec(cmd)