diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-12-31 01:52:46 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-12-31 01:52:46 -0800 |
| commit | 811aefd0dfdb0bc93ffa8e2c6283c372159ff4ea (patch) | |
| tree | f469bc9713787da8490db893799ac6b3d8b8b8cf | |
| parent | 0ae59c5a90c19bc562af23969b014c368540c241 (diff) | |
Added replace -q and chmod +x'd two tools.
| -rwxr-xr-x[-rw-r--r--] | tools/repl.nom | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | tools/replace.nom | 15 |
2 files changed, 8 insertions, 7 deletions
diff --git a/tools/repl.nom b/tools/repl.nom index 983de5f..983de5f 100644..100755 --- a/tools/repl.nom +++ b/tools/repl.nom diff --git a/tools/replace.nom b/tools/replace.nom index 2737ce0..7abe960 100644..100755 --- a/tools/replace.nom +++ b/tools/replace.nom @@ -3,7 +3,7 @@ This is a tool to replace syntax trees with something new. Usage: - nomsu -t replace [-i] [--literal="$v1 $v2..."] <pattern> <replacement> file1 file2... + nomsu -t replace [-i] [-f] [-q] [--literal="$v1 $v2..."] <pattern> <replacement> file1 file2... Example: nomsu -t replace "($1 and $2) and $3" "all of [$1, $2, $3]" my_file.nom @@ -11,6 +11,8 @@ If the "-i" flag is used, the file(s) will be edited in-place. When editing in-place, if the "-f" flag is not used, each change will be run past the user first. + If the "-q" flag is used and a file fails to parse, the original file + contents will be output. If no files are passed in, this will read from stdin. use "lib/os.nom" @@ -89,12 +91,11 @@ for $filename in $filenames: try: $tree = ($code parsed) ..and if it barfs $msg: - say - red (" - \$filename failed to parse: - \$msg - ") - $tree = (nil) + if $(COMMAND LINE ARGS).q: + unless $(COMMAND LINE ARGS).i: + say $code + ..else: + say $msg unless $tree: do next $filename |
