diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-12-19 02:27:10 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-12-19 02:27:10 -0800 |
| commit | f75fc15cdfd9d6727b7c8489abfc2165ca0f114b (patch) | |
| tree | 449bb72c569d539c5a3e5dc52b93c89bad121f99 /tools | |
| parent | a7d912a33ae1f6857e5abbda1997bcf1fff2a83d (diff) | |
Updated to be more fault tolerant with "-q" flag
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/format.nom | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/tools/format.nom b/tools/format.nom index 8355176..0f09834 100755 --- a/tools/format.nom +++ b/tools/format.nom @@ -21,11 +21,20 @@ for $filename in $filenames: barf "File does not exist: \$filename" $leading_indent = ($file|matching "[\n]*([ ]*)") $code = (NomsuCode from ($Source $filename 1 (size of $file)) $file) - $tree = ($code parsed) - $formatted = " - \$leading_indent\((($tree as nomsu)|text)|with "\n" -> "\n\$leading_indent")" + try: + $tree = ($code parsed) + ..and if it barfs $msg: + if $(COMMAND LINE ARGS)."-q": + $formatted = $file + ..else: + say $msg + + if ($tree and (not $formatted)): + $formatted = " + \$leading_indent\((($tree as nomsu)|text)|with "\n" -> "\n\$leading_indent")" - if $(COMMAND LINE ARGS)."-i": - write $formatted to file $filename - ..else: - say $formatted inline + if $formatted: + if $(COMMAND LINE ARGS)."-i": + write $formatted to file $filename + ..else: + say $formatted inline |
