Skip to content

Commit 1e72e6c

Browse files
added diff option to rewrite (fixes #21)
1 parent 4e86c88 commit 1e72e6c

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/comby/binary.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def rewrite(self,
111111
rewrite: str,
112112
args: Optional[Dict[str, str]] = None,
113113
*,
114+
diff: bool = False,
114115
language: Optional[str] = None
115116
) -> str:
116117
logger.info("performing rewriting of source (%s) using match template "
@@ -128,7 +129,8 @@ def rewrite(self,
128129
raise NotImplementedError("args are not currently supported")
129130

130131
cmd = ['-stdin', shlex.quote(match), shlex.quote(rewrite)]
131-
cmd += ['-stdout', '-matcher', shlex.quote(language)]
132+
cmd += ['-matcher', shlex.quote(language)]
133+
cmd += ['-diff' if diff else '-stdout']
132134
cmd_s = ' '.join(cmd)
133135

134136
return self.call(cmd_s, text=source)

src/comby/interface.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def rewrite(self,
7474
rewrite: str,
7575
args: Optional[Dict[str, str]] = None,
7676
*,
77+
diff: bool = False,
7778
language: Optional[str] = None
7879
) -> str:
7980
"""

0 commit comments

Comments
 (0)