summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xlib/pure/os.nim18
-rwxr-xr-xtools/nimgrep.nim19
-rwxr-xr-xweb/news.txt4
3 files changed, 33 insertions, 8 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index 987662975..9fafed71b 100755
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -1165,7 +1165,7 @@ when defined(macosx):
   proc getExecPath2(c: cstring, size: var int32): bool {.
     importc: "_NSGetExecutablePath", header: "<mach-o/dyld.h>".}
 
-proc getApplicationFilename*(): string {.rtl, extern: "nos$1".} =
+proc getAppFilename*(): string {.rtl, extern: "nos$1".} =
   ## Returns the filename of the application's executable.
 
   # Linux: /proc/<pid>/exe
@@ -1202,9 +1202,21 @@ proc getApplicationFilename*(): string {.rtl, extern: "nos$1".} =
           var x = joinPath(p, result)
           if ExistsFile(x): return x
 
-proc getApplicationDir*(): string {.rtl, extern: "nos$1".} =
+proc getApplicationFilename*(): string {.rtl, extern: "nos$1", deprecated.} =
+  ## Returns the filename of the application's executable.
+  ## **Deprecated since version 0.8.12**: use ``getAppFilename`` 
+  ## instead.
+  result = getAppFilename()
+
+proc getApplicationDir*(): string {.rtl, extern: "nos$1", deprecated.} =
+  ## Returns the directory of the application's executable.
+  ## **Deprecated since version 0.8.12**: use ``getAppDir`` 
+  ## instead.
+  result = splitFile(getAppFilename()).dir
+
+proc getAppDir*(): string {.rtl, extern: "nos$1".} =
   ## Returns the directory of the application's executable.
-  result = splitFile(getApplicationFilename()).dir
+  result = splitFile(getAppFilename()).dir
 
 proc sleep*(milsecs: int) {.rtl, extern: "nos$1".} =
   ## sleeps `milsecs` milliseconds.
diff --git a/tools/nimgrep.nim b/tools/nimgrep.nim
index 0418e18ce..1fef74c7d 100755
--- a/tools/nimgrep.nim
+++ b/tools/nimgrep.nim
@@ -16,7 +16,7 @@ const
 
   (c) 2011 Andreas Rumpf
 Usage:
-  nimgrep [options] [pattern] (file/directory)*
+  nimgrep [options] [pattern] [replacement] (file/directory)*
 Options:
   --find, -f          find the pattern (default)
   --replace, -r       replace the pattern
@@ -29,8 +29,9 @@ Options:
   --stdin             read pattern from stdin (to avoid the shell's confusing
                       quoting rules)
   --word, -w          the pattern should have word boundaries
-  --ignore_case, -i   be case insensitive
-  --ignore_style, -y  be style insensitive
+  --ignoreCase, -i    be case insensitive
+  --ignoreStyle, -y   be style insensitive
+  --ext:EX1|EX2|...   only search the files with the given extension(s)
   --help, -h          shows this help
   --version, -v       shows the version
 """
@@ -47,6 +48,7 @@ var
   filenames: seq[string] = @[]
   pattern = ""
   replacement = ""
+  extensions: seq[string] = @[]
   options: TOptions
 
 proc ask(msg: string): string =
@@ -180,6 +182,10 @@ proc processFile(filename: string) =
     else:
       quit "cannot open file for overwriting: " & filename
 
+proc hasRightExt(filename: string, exts: seq[string]): bool =
+  var y = splitFile(filename).ext.copy(1) # skip leading '.'
+  for x in items(exts): 
+    if os.cmpPaths(x, y) == 0: return true
 
 proc walker(dir: string) = 
   var isDir = false
@@ -187,7 +193,8 @@ proc walker(dir: string) =
     isDir = true
     case kind
     of pcFile: 
-      processFile(path)
+      if extensions.len == 0 or path.hasRightExt(extensions):
+        processFile(path)
     of pcDir: 
       if optRecursive in options:
         walker(path)
@@ -224,6 +231,7 @@ for kind, key, val in getopt():
     of "word", "w": incl(options, optWord)
     of "ignorecase", "i": incl(options, optIgnoreCase)
     of "ignorestyle", "y": incl(options, optIgnoreStyle)
+    of "ext": extensions = val.split('|')
     of "help", "h": writeHelp()
     of "version", "v": writeVersion()
     else: writeHelp()
@@ -243,7 +251,8 @@ if optStdin in options:
 if pattern.len == 0:
   writeHelp()
 else: 
-  if filenames.len == 0: filenames.add(os.getCurrentDir())
+  if filenames.len == 0: 
+    filenames.add(os.getCurrentDir())
   if optRegex notin options: 
     if optIgnoreStyle in options: 
       pattern = "\\y " & pattern
diff --git a/web/news.txt b/web/news.txt
index 36deb92df..7f013732a 100755
--- a/web/news.txt
+++ b/web/news.txt
@@ -28,6 +28,10 @@ Changes affecting backwards compatibility
 
 - Operators starting with ``^`` are now right-associative and have the highest 
   priority.
+- Deprecated ``os.getApplicationFilename``: Use ``os.getAppFilename`` 
+  instead.
+- Deprecated ``os.getApplicationDir``: Use ``os.getAppDir`` 
+  instead.
 
 
 Additions