diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2019-03-20 14:15:17 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2019-03-20 14:15:17 -0700 |
| commit | 12db69cdd64e95a917824643d31a712618a6d014 (patch) | |
| tree | af72963dba3a2ae1e5e752d19a948db697952181 /lib/tools | |
| parent | a09b66d72509111e57fb19368d2188a8b71d678e (diff) | |
Slight tweaking and updating syntax
Diffstat (limited to 'lib/tools')
| -rwxr-xr-x | lib/tools/format.nom | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/tools/format.nom b/lib/tools/format.nom index c2e6a1c..c8764a3 100755 --- a/lib/tools/format.nom +++ b/lib/tools/format.nom @@ -1,5 +1,5 @@ -#!/usr/bin/env nomsu -V6.15.13.8 -# +#!/usr/bin/env nomsu -V7 +### Auto-format Nomsu code. Usage: nomsu -t format [-i] file1 file2... @@ -14,7 +14,7 @@ use "commandline" command line program with $args: $filenames = $args.extras - if ((#$filenames) == 0): + if (#$filenames == 0): say (" Warning: reading from stdin (ctrl-d to abort). To avoid this message, use nomsu -t format - ") @@ -25,21 +25,18 @@ command line program with $args: unless $file: fail "File does not exist: \$filename" $leading_indent = ($file, matching "^\n*([ ]*)") - $code = (NomsuCode from ($Source $filename 1 (size of $file)) $file) + $code = (NomsuCode from (Source $filename 1 #$file) $file) try: $tree = ($code parsed) + $formatted = ($tree as nomsu, text, indented $leading_indent) ..if it fails with $msg: - $tree = (nil) if $args.q: $formatted = $file ..else: say $msg + do next $filename - if $tree: - $formatted = ($tree as nomsu, text, indented $leading_indent) - - if $formatted: - if $args.i: - write $formatted to file $filename - ..else: - say $formatted inline + if $args.i: + write $formatted to file $filename + ..else: + say $formatted inline |
