Show a patch operation as a mini diff.
(path, old_str, new_str)
| 73 | border_style='green', box=box.ROUNDED)) |
| 74 | |
| 75 | def show_patch(path, old_str, new_str): |
| 76 | """Show a patch operation as a mini diff.""" |
| 77 | fname = Path(path).name |
| 78 | diff_text = Text() |
| 79 | for line in old_str.splitlines(): |
| 80 | diff_text.append(f'- {line}\n', style='red') |
| 81 | for line in new_str.splitlines(): |
| 82 | diff_text.append(f'+ {line}\n', style='green') |
| 83 | console.print(Panel(diff_text, title=f'Patching {fname}', |
| 84 | border_style='yellow', box=box.ROUNDED)) |
| 85 | |
| 86 | def show_shell(command, output, error=False): |
| 87 | """Show shell command and its output.""" |