Rename execute to pipe
This commit is contained in:
parent
b148bba4b2
commit
8975db2cc9
2 changed files with 11 additions and 10 deletions
|
|
@ -160,7 +160,7 @@ The following keys apply to library source code (before processing) and generate
|
||||||
|
|
||||||
```search``` = search string providing context for following prepend/append/replace directives
|
```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
|
```prepend``` = string value to prepend into file at beginning or before search
|
||||||
|
|
||||||
|
|
|
||||||
19
nimgen.nim
19
nimgen.nim
|
|
@ -255,11 +255,12 @@ proc prepend(file: string, data: string, search="") =
|
||||||
if idx != -1:
|
if idx != -1:
|
||||||
content = content[0..<idx] & data & content[idx..<content.len()]
|
content = content[0..<idx] & data & content[idx..<content.len()]
|
||||||
|
|
||||||
proc execute(file: string, command: string) =
|
proc pipe(file: string, command: string) =
|
||||||
withFile(file):
|
let cmd = command % ["file", file]
|
||||||
let cmd = command % ["file", file]
|
let commandResult = execProc(cmd).strip()
|
||||||
let commandResult = execProc(cmd)
|
if commandResult != "":
|
||||||
content = commandResult
|
withFile(file):
|
||||||
|
content = commandResult
|
||||||
|
|
||||||
proc append(file: string, data: string, search="") =
|
proc append(file: string, data: string, search="") =
|
||||||
withFile(file):
|
withFile(file):
|
||||||
|
|
@ -613,10 +614,10 @@ proc doActions(file: string, c2nimConfig: var c2nimConfigObj, cfg: OrderedTableR
|
||||||
if val == true:
|
if val == true:
|
||||||
if action == "create":
|
if action == "create":
|
||||||
createDir(file.splitPath().head)
|
createDir(file.splitPath().head)
|
||||||
writeFile(file, cfg[act].addEnv())
|
writeFile(file, cfg[act])
|
||||||
elif action in @["prepend", "append", "replace", "comment",
|
elif action in @["prepend", "append", "replace", "comment",
|
||||||
"rename", "compile", "dynlib", "pragma",
|
"rename", "compile", "dynlib", "pragma",
|
||||||
"execute"] and sfile != "":
|
"pipe"] and sfile != "":
|
||||||
if action == "prepend":
|
if action == "prepend":
|
||||||
if srch != "":
|
if srch != "":
|
||||||
prepend(sfile, cfg[act].addEnv(), cfg[srch].addEnv())
|
prepend(sfile, cfg[act].addEnv(), cfg[srch].addEnv())
|
||||||
|
|
@ -641,8 +642,8 @@ proc doActions(file: string, c2nimConfig: var c2nimConfigObj, cfg: OrderedTableR
|
||||||
c2nimConfig.dynlib.add(cfg[act].addEnv())
|
c2nimConfig.dynlib.add(cfg[act].addEnv())
|
||||||
elif action == "pragma":
|
elif action == "pragma":
|
||||||
c2nimConfig.pragma.add(cfg[act].addEnv())
|
c2nimConfig.pragma.add(cfg[act].addEnv())
|
||||||
elif action == "execute":
|
elif action == "pipe":
|
||||||
execute(sfile, cfg[act].addEnv())
|
pipe(sfile, cfg[act].addEnv())
|
||||||
srch = ""
|
srch = ""
|
||||||
elif action == "search":
|
elif action == "search":
|
||||||
srch = act
|
srch = act
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue