all repos — fae @ aebd7aa36a54addf0edfbbdf9566ba894fb2f414

A minuscule find and edit utility.

Prepared for release.
h3rald h3rald@h3rald.com
Sun, 08 Nov 2020 15:44:17 +0100
commit

aebd7aa36a54addf0edfbbdf9566ba894fb2f414

parent

d07d92aaa5fcf0b38a695564c95be57add833264

6 files changed, 94 insertions(+), 14 deletions(-)

jump to
M .gitignore.gitignore

@@ -1,3 +1,4 @@

packages/ fae test/ +*.zip
M README.mdREADME.md

@@ -1,5 +1,5 @@

-# FAE v1.0.0 - Find & Edit Utility - +# Fae (Find & Edit Utility) v1.0.0 + ``` (c) 2020 Fabio Cevasco
M fae.nimsrc/fae.nim

@@ -1,11 +1,12 @@

import - packages/nim-sgregex/sgregex, + ../packages/nim-sgregex/sgregex, std/exitprocs, parseopt, os, terminal, strutils, - times + times, + faepkg/config type StringBounds = array[0..1, int]

@@ -22,22 +23,21 @@ silent: bool

addExitProc(resetAttributes) -const version = "1.0.0" - -const usage = """FAE v""" & version & """ - Find & Edit Utility - (c) 2020 Fabio Cevasco +const usage = appName & """ (""" & appDescription & """) v""" & appVersion & """ + (c) 2020 """ & appAuthor & """ Usage: fae <pattern> <replacement> [option1 option2 ...] Where: - <pattern> A regular expression to search for - <replacement> An optional replacement string + <pattern> A regular expression to search for. + <replacement> An optional replacement string + (use \1, \2, etc. to reference captured groups). Options: - -a, --apply Substitute all occurrences of <pattern> with <replacement> in all files - without asking for confirmation. - -d, --directory Search in the specified directory (default: .) + -a, --apply Substitute all occurrences of <pattern> with <replacement> + in all files without asking for confirmation. + -d, --directory Search in the specified directory (default: .). -f, --filter Specify a regular expression to filter file paths. -h, --help Display this message. -i, --insensitive Case-insensitive matching.

@@ -203,7 +203,7 @@ of "help", "h":

echo usage quit(0) of "version", "v": - echo version + echo appVersion quit(0) of "insensitive", "i": options.insensitive = true
M fae.nim.cfgsrc/fae.nim.cfg

@@ -1,4 +1,5 @@

gc:orc +opt:size # https://blog.filippo.io/easy-windows-and-linux-cross-compilers-for-macos/
A fae.nimble

@@ -0,0 +1,73 @@

+import + strutils + +from os import parentDir, `/` + +template thisModuleFile: string = instantiationInfo(fullPaths = true).filename + +when fileExists(thisModuleFile.parentDir / "src/faepkg/config.nim"): + # In the git repository the Nimble sources are in a ``src`` directory. + import src/faepkg/config +else: + # When the package is installed, the ``src`` directory disappears. + import faepkg/config + +# Package + +version = appVersion +author = appAuthor +description = appDescription +license = appLicense +bin = @[appName] +srcDir = "src" +installExt = @["nim", "c", "h"] + +# Dependencies + +requires "nim >= 1.4.0", "nifty" + +before install: + exec "nimble install nifty" + exec "nifty install" + +# Build + +const + parallel = "" #"--parallelBuild:1 --verbosity:3" + compile = "nim c -d:release --opt:size" & " " & parallel + linux_x64 = "--cpu:amd64 --os:linux --passL:-static" + windows_x64 = "--cpu:amd64 --os:windows" + macosx_x64 = "" + app = "src/fae" + app_file = "src/fae.nim" + zip = "zip -X -j" + +proc shell(command, args = "", dest = "") = + exec command & " " & args & " " & dest + +proc filename_for(os: string, arch: string): string = + return appName & "_v" & version & "_" & os & "_" & arch & ".zip" + +task windows_x64_build, "Build " & appName & " for Windows (x64)": + shell compile, windows_x64, app_file + +task linux_x64_build, "Build " & appName & " for Linux (x64)": + shell compile, linux_x64, app_file + +task macosx_x64_build, "Build " & appName & " for Mac OS X (x64)": + shell compile, macosx_x64, app_file + +task release, "Release " & appName: + echo "\n\n\n WINDOWS - x64:\n\n" + windows_x64_buildTask() + shell zip, "$1 $2" % [filename_for("windows", "x64"), app & ".exe"] + shell "rm", app & ".exe" + echo "\n\n\n LINUX - x64:\n\n" + linux_x64_buildTask() + shell zip, "$1 $2" % [filename_for("linux", "x64"), app] + shell "rm", app + echo "\n\n\n MAC OS X - x64:\n\n" + macosx_x64_buildTask() + shell zip, "$1 $2" % [filename_for("macosx", "x64"), app] + shell "rm", app + echo "\n\n\n ALL DONE!"
A src/faepkg/config.nim

@@ -0,0 +1,5 @@

+const appName* = "fae" +const appDescription* = "Find and Edit Utility" +const appVersion* = "1.0.0" +const appLicense* = "MIT" +const appAuthor* = "Fabio Cevasco"