From 8e52f1901b73f2072d21f8c79ef52bf137180161 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 18 Dec 2018 19:25:10 -0800 Subject: Renamed autoformat -> format for concision (it's obviously auto, it's a tool). --- tools/autoformat.nom | 31 ------------------------------- tools/format.nom | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 31 deletions(-) delete mode 100755 tools/autoformat.nom create mode 100755 tools/format.nom (limited to 'tools') diff --git a/tools/autoformat.nom b/tools/autoformat.nom deleted file mode 100755 index d878a02..0000000 --- a/tools/autoformat.nom +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env nomsu -V5.12.12.8 -# - Auto-format Nomsu code. Usage: - nomsu -t autoformat [-i] file1 file2... - - If the "-i" flag is used, the file will be edited in-place. - If no files are passed in, this will read from stdin. - -use "lib/os.nom" - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -$filenames = $(COMMAND LINE ARGS).extras -if ((#$filenames) == 0): - say "Warning: reading from stdin (ctrl-d to abort). To avoid this message, use nomsu -t autoformat -" - $filenames = ["stdin"] - -for $filename in $filenames: - $file = (read file $filename) - unless $file: - 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")" - - if $(COMMAND LINE ARGS)."-i": - write $formatted to file $filename - ..else: - say $formatted inline diff --git a/tools/format.nom b/tools/format.nom new file mode 100755 index 0000000..8355176 --- /dev/null +++ b/tools/format.nom @@ -0,0 +1,31 @@ +#!/usr/bin/env nomsu -V5.12.12.8 +# + Auto-format Nomsu code. Usage: + nomsu -t format [-i] file1 file2... + + If the "-i" flag is used, the file will be edited in-place. + If no files are passed in, this will read from stdin. + +use "lib/os.nom" + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +$filenames = $(COMMAND LINE ARGS).extras +if ((#$filenames) == 0): + say "Warning: reading from stdin (ctrl-d to abort). To avoid this message, use nomsu -t format -" + $filenames = ["stdin"] + +for $filename in $filenames: + $file = (read file $filename) + unless $file: + 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")" + + if $(COMMAND LINE ARGS)."-i": + write $formatted to file $filename + ..else: + say $formatted inline -- cgit v1.2.3