From e675621d3c58c950ae1a12e7b6971b4af3958637 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 26 Nov 2018 16:28:38 -0800 Subject: [PATCH] Removed "replace" tool. --- tools/replace.nom | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100755 tools/replace.nom diff --git a/tools/replace.nom b/tools/replace.nom deleted file mode 100755 index 3ce2411..0000000 --- a/tools/replace.nom +++ /dev/null @@ -1,39 +0,0 @@ -#!/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 ... - If "-i" is the first argument, replacements will be performed in-place. Otherwise, the - upgraded code will be printed. - -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) -for %filename in %args.extra_args at %i: - if (%i < 3): - do next %i - %file = (read file %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)) - if (%tree2 == %tree): - say "No changes in \%filename" - do next %filename - %text = ((%tree2 as nomsu)::text) - when: - %args."-i": - say "Replaced in \%filename" - write %text to file %filename - - else: - say %text