diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-12-31 01:37:24 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-12-31 01:38:23 -0800 |
| commit | 6edf6a275574cf8c3cb6a7015e22d0c982e2e489 (patch) | |
| tree | 00626e989a2878501c9bfd340cd3b4db2a07e8e4 /tools | |
| parent | 7762c8c45b6f0349d769682b26349fb25a7a8657 (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')
| -rwxr-xr-x | tools/find.nom | 4 | ||||
| -rwxr-xr-x | tools/format.nom | 5 | ||||
| -rwxr-xr-x | tools/test.nom | 6 | ||||
| -rwxr-xr-x | tools/upgrade.nom | 8 |
4 files changed, 12 insertions, 11 deletions
diff --git a/tools/find.nom b/tools/find.nom index d07681a..781ca3f 100755 --- a/tools/find.nom +++ b/tools/find.nom @@ -21,7 +21,7 @@ use "lib/consolecolor.nom" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -$wildcard = ($(COMMAND LINE ARGS)."--wildcard" or "%*") +$wildcard = ($(COMMAND LINE ARGS).wildcard or "%*") $pattern = $(COMMAND LINE ARGS).extras.1 if (any of [not $pattern, $pattern == "*", $pattern == "**"]): barf (" @@ -84,7 +84,7 @@ for $filename in $filenames: if ($sub is syntax tree): recurse $t on $sub - if $(COMMAND LINE ARGS)."-l": + if $(COMMAND LINE ARGS).l: if ((#$results) > 0): say $filename ..else: 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 diff --git a/tools/test.nom b/tools/test.nom index 67afb96..d9e9269 100755 --- a/tools/test.nom +++ b/tools/test.nom @@ -33,14 +33,14 @@ for $filename in $(COMMAND LINE ARGS).extras: sort $file_tests by $ -> $.source lua> "io.write('[ .. ] ', \$filename); io.flush()" - if (command line args)."-v": say "" + if (command line args).v: say "" for $ in $file_tests: - if (command line args)."-v": + if (command line args).v: say " \(yellow ($.test, with "\n" -> "\n "))" run $.test - if (command line args)."-v": + if (command line args).v: say (green "PASS") ..else: say "\r[\(green "PASS")" diff --git a/tools/upgrade.nom b/tools/upgrade.nom index ccb12b5..5cf7d60 100755 --- a/tools/upgrade.nom +++ b/tools/upgrade.nom @@ -11,10 +11,10 @@ use "lib/consolecolor.nom" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -$inplace = ($(COMMAND LINE ARGS)."-i" or $(COMMAND LINE ARGS)."--inplace") -$start_version = $(COMMAND LINE ARGS)."--upgrade-from" -$version = ($(COMMAND LINE ARGS)."--upgrade-to" or (Nomsu version)) -$test = ($(COMMAND LINE ARGS)."-t" or $(COMMAND LINE ARGS)."--test") +$inplace = ($(COMMAND LINE ARGS).i or $(COMMAND LINE ARGS).inplace) +$start_version = $(COMMAND LINE ARGS)."upgrade-from" +$version = ($(COMMAND LINE ARGS)."upgrade-to" or (Nomsu version)) +$test = ($(COMMAND LINE ARGS).t or $(COMMAND LINE ARGS).test) for $filename in $(COMMAND LINE ARGS).extras: $file = (read file $filename) unless $file: |
