aboutsummaryrefslogtreecommitdiff
path: root/tools/format.nom
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-12-31 01:37:24 -0800
committerBruce Hill <bruce@bruce-hill.com>2018-12-31 01:38:23 -0800
commit6edf6a275574cf8c3cb6a7015e22d0c982e2e489 (patch)
tree00626e989a2878501c9bfd340cd3b4db2a07e8e4 /tools/format.nom
parent7762c8c45b6f0349d769682b26349fb25a7a8657 (diff)
Overhaul of command line argument parsing. Now supports "-abc" as 3
flags, and stores them as .a, .b, .c instead of ."-a", etc. (same for --args)
Diffstat (limited to 'tools/format.nom')
-rwxr-xr-xtools/format.nom5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/format.nom b/tools/format.nom
index 65cc2ca..df89635 100755
--- a/tools/format.nom
+++ b/tools/format.nom
@@ -4,6 +4,7 @@
nomsu -t format [-i] file1 file2...
If the "-i" flag is used, the file will be edited in-place.
+ If the "-q" flag is used and an error occurs, the original file will be printed.
If no files are passed in, this will read from stdin.
use "lib/os.nom"
@@ -26,7 +27,7 @@ for $filename in $filenames:
try:
$tree = ($code parsed)
..and if it barfs $msg:
- if $(COMMAND LINE ARGS)."-q":
+ if $(COMMAND LINE ARGS).q:
$formatted = $file
..else:
say $msg
@@ -36,7 +37,7 @@ for $filename in $filenames:
"\$leading_indent\($tree as nomsu, text, with "\n" -> "\n\$leading_indent")"
if $formatted:
- if $(COMMAND LINE ARGS)."-i":
+ if $(COMMAND LINE ARGS).i:
write $formatted to file $filename
..else:
say $formatted inline