diff options
| -rw-r--r-- | patchtree/cli.py | 11 | ||||
| -rw-r--r-- | patchtree/context.py | 9 |
2 files changed, 12 insertions, 8 deletions
diff --git a/patchtree/cli.py b/patchtree/cli.py index f127d1c..83b955d 100644 --- a/patchtree/cli.py +++ b/patchtree/cli.py @@ -132,14 +132,11 @@ def main(): context = parse_arguments(config) - patch = context.make_patch() - - if not context.in_place: - context.output.write(patch) - context.output.flush() - context.output.close() + if context.in_place: + context.apply(True) + context.apply(False) else: - raise NotImplementedError("TODO") + context.write() return 0 diff --git a/patchtree/context.py b/patchtree/context.py index 65f9568..801923f 100644 --- a/patchtree/context.py +++ b/patchtree/context.py @@ -431,7 +431,7 @@ class Context: raise Exception("cannot edit zip in-place!") return ZipFS(target) - raise Exception("cannot read `{target}'") + raise Exception(f"cannot read `{target}'") def _get_output(self, options: Namespace) -> IO: """ @@ -440,6 +440,8 @@ class Context: :returns: Output stream. """ if options.in_place: + if options.out is not None: + self.log.warning("--out is ignored when using --in-place") return TextIO() if options.out is not None: @@ -496,3 +498,8 @@ class Context: cmd.append(str(cache.absolute())) run(cmd, cwd=str(location.absolute())) + + def write(self) -> None: + patch = self.make_patch() + self.output.write(patch) + self.output.close() |