nomsu/tools/autoformat.nom
Bruce Hill 4efe44ed27 Fully upgraded to 4.10.12.7, including deprecating the old list/dict
comprehension methods, in favor of the new native support.
2018-11-11 15:50:46 -08:00

29 lines
865 B
Plaintext
Executable File

#!/usr/bin/env nomsu -V4.10.12.7
#
Auto-format Nomsu code. Usage:
nomsu tools/autoformat.nom [-i] file1 file2 directory1 ...
If the first argument is "-i", modifications will be performed in-place. Otherwise,
the formatted code will be printed.
use "lib/os.nom"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%args = (command line args)
%inplace = (no)
if (%args.1 is "-i"):
%inplace = (yes)
%args::remove index 1
for %path in %args:
for file %filename in %path:
unless (%filename::matches "%.nom$"): do next %filename
%formatted = "\
..#!/usr/bin/env nomsu -V\(Nomsu version)
\((parse (read file %filename) from %filename) as nomsu)"
if %inplace:
write %formatted to file %filename
..else:
say %formatted