diff options
| -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 |
