diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-11-26 16:28:06 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-11-26 16:28:06 -0800 |
| commit | 5027bd4f0f2c6dcebf667a6924c50b0ca3df235f (patch) | |
| tree | da3ed710dcbfc065a24ac3ab0c8b4917a22b6991 /tools/replace.nom | |
| parent | 8e5f1b9e1e912f781738a564843e024b0e0b2e96 (diff) | |
Upgraded/autoformatted.
Diffstat (limited to 'tools/replace.nom')
| -rwxr-xr-x | tools/replace.nom | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/tools/replace.nom b/tools/replace.nom index 66ca690..3ce2411 100755 --- a/tools/replace.nom +++ b/tools/replace.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V4.11.12.8 +#!/usr/bin/env nomsu -V4.12.12.8 # Tool to find and replace one tree with another. nomsu tools/replace.nom [-i] tree_to_replace replacement file1 file2 directory1 ... @@ -10,29 +10,25 @@ use "lib/os.nom" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ barf "Deprecated." - if ((size of %args.extra_args) < 3): say "Usage: nomsu tools/replace.nom [-i] tree_to_replace replacement files..." lua> "os.exit(1)" - -%pattern = ((%args.extra_args.1) parsed) -%replacement = ((%args.extra_args.2) parsed) +%pattern = (%args.extra_args.1 parsed) +%replacement = (%args.extra_args.2 parsed) for %filename in %args.extra_args at %i: - if (%i < 3): do next %i + if (%i < 3): + do next %i %file = (read file %filename) - unless %file: barf "File does not exist: \%filename" + unless %file: + barf "File does not exist: \%filename" %nomsu = (NomsuCode from (Source %filename 1 (size of %file)) %file) %tree = (%nomsu parsed) + # TODO: fix this to use variable substitution - %tree2 = (..) - %tree::map (..) - for %subtree: - if (%subtree == %pattern): - return %replacement + %tree2 = (%tree::map (for %subtree: if (%subtree == %pattern): return %replacement)) if (%tree2 == %tree): say "No changes in \%filename" do next %filename - %text = ((%tree2 as nomsu)::text) when: %args."-i": |
