From e371546d522b1ce39a1009552a43de614368279a Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Sat, 16 Jun 2018 15:33:47 +0900 Subject: Add support for executing a command on a file. $file in the command string references the file name. The stdout of the command will become the file's new contents. This is useful for doing things that nimgen might not support, like using sed or grep or some other command line tool. --- README.md | 2 ++ nimgen.nim | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d47239e..0c4bb89 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,8 @@ The following keys apply to library source code (before processing) and generate ```search``` = search string providing context for following prepend/append/replace directives +```execute``` = execute a command on a file and store the output of the command as the new file contents. Ex: execute = "cat $file | grep 'static inline'" + ```prepend``` = string value to prepend into file at beginning or before search ```append``` = string value to append into file at the end or after search diff --git a/nimgen.nim b/nimgen.nim index d804657..cff48e3 100644 --- a/nimgen.nim +++ b/nimgen.nim @@ -228,6 +228,12 @@ proc prepend(file: string, data: string, search="") = if idx != -1: content = content[0.. Date: Wed, 27 Jun 2018 22:22:38 +0900 Subject: Rename execute to pipe --- README.md | 2 +- nimgen.nim | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0c4bb89..a92a5dc 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ The following keys apply to library source code (before processing) and generate ```search``` = search string providing context for following prepend/append/replace directives -```execute``` = execute a command on a file and store the output of the command as the new file contents. Ex: execute = "cat $file | grep 'static inline'" +```pipe``` = execute a command on a file and store the output of the command as the new file contents. Ex: pipe = "cat $file | grep 'static inline'" ```prepend``` = string value to prepend into file at beginning or before search diff --git a/nimgen.nim b/nimgen.nim index cff48e3..82b072a 100644 --- a/nimgen.nim +++ b/nimgen.nim @@ -228,11 +228,12 @@ proc prepend(file: string, data: string, search="") = if idx != -1: content = content[0..