aboutsummaryrefslogtreecommitdiff
path: root/tools/format.nom
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-12-19 02:27:10 -0800
committerBruce Hill <bruce@bruce-hill.com>2018-12-19 02:27:10 -0800
commitf75fc15cdfd9d6727b7c8489abfc2165ca0f114b (patch)
tree449bb72c569d539c5a3e5dc52b93c89bad121f99 /tools/format.nom
parenta7d912a33ae1f6857e5abbda1997bcf1fff2a83d (diff)
Updated to be more fault tolerant with "-q" flag
Diffstat (limited to 'tools/format.nom')
-rwxr-xr-xtools/format.nom23
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