Skip to content

Commit

Permalink
Merge pull request #23 from Don-Felice/nicer_reports
Browse files Browse the repository at this point in the history
feat(sed): nicer reporting
  • Loading branch information
Don-Felice authored Feb 22, 2024
2 parents 2e2603a + 94ba5cc commit a7f31f1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased Changes

- streaming editor: nicer reporting

## v1.5.0 - Feb. 22, 2024

Expand Down
13 changes: 6 additions & 7 deletions clifs/plugins/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ def init_parser(cls, parser: ArgumentParser) -> None:
"--max_previews",
type=int,
default=5,
help="Max number of changes shown in preview mode. Each line in a file "
"where 'pattern' matches at least once counts as a change. "
help="Maximum number of line changes shown in the preview mode. "
"Set to zero to skip preview mode completely. Only for the brave...",
)

Expand Down Expand Up @@ -167,7 +166,7 @@ def run(self) -> None:
self.replace(file)
self.progress["overall"].update(
self.tasks["progress"],
last_action=f"Edited: {file.name}",
last_action=f"edited '{file.name}'",
)
self.progress["overall"].advance(self.tasks["progress"])
self.progress["counts"].advance(self.tasks["files_edited"])
Expand Down Expand Up @@ -227,8 +226,8 @@ def get_tasks(self) -> Dict[str, TaskID]:
tasks["files_edited"] = self.progress["counts"].add_task(
"Files edited:", total=None
)
tasks["total_replacements"] = self.progress["counts"].add_task(
"Total replacements:", total=None
tasks["lines_changed_total"] = self.progress["counts"].add_task(
"Lines modified:", total=None
)
return tasks

Expand Down Expand Up @@ -292,7 +291,7 @@ def replace(self, input_file: Path) -> None:
mod_line = re.sub(self.pattern, self.replacement, line)
if mod_line != line:
self.progress["counts"].advance(
self.tasks["total_replacements"]
self.tasks["lines_changed_total"]
)
output_fh.write(mod_line)
else:
Expand All @@ -301,7 +300,7 @@ def replace(self, input_file: Path) -> None:
mod_line = re.sub(self.pattern, self.replacement, line)
if mod_line != line:
self.progress["counts"].advance(
self.tasks["total_replacements"]
self.tasks["lines_changed_total"]
)
output_fh.write(mod_line)
else:
Expand Down
Binary file modified doc/imgs/example_sed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a7f31f1

Please sign in to comment.