Skip to content

Commit

Permalink
revert the previous changes and add a wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
laowantong committed Mar 5, 2022
1 parent 844284a commit a65fa29
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/suprenam.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@
from src.user_types import EditedText


def main():
def main_wrapper():
previous_log_text = logger.get_contents()
logger.create_new_log_file()
logger.info("Starting the program.")
main(previous_log_text)
logger.info("Exiting the program.")


def main(previous_log_text: str):
logger.info("Parsing arguments.")
args = cli_arguments()
logger.info("Parsing arguments done.")
Expand All @@ -50,7 +55,10 @@ def main():
arcs_for_undoing = renamer.get_arcs_for_undoing(previous_log_text)
logger.info(str(arcs_for_undoing))
message = renamer.perform_renamings(arcs_for_undoing)
print_.success(f"The previous renaming session was undone. {message} " "Launch Suprenam again to restore.")
print_.success(
f"The previous renaming session was undone. {message} "
"Launch Suprenam again to restore."
)
except RecoverableRenamingError:
try:
renamer.rollback_renamings()
Expand All @@ -60,7 +68,6 @@ def main():
except Exception as e: # Unknown problem with the log file, e.g. not found
return print_.fail(f"Unrecoverable failure during undo: {e}")
logger.info("Undoing renamings done.")
logger.info("Exiting the program.")


def run_on_path_list(paths: List[Path]):
Expand Down Expand Up @@ -178,4 +185,4 @@ def cli_arguments():


if __name__ == "__main__": # pragma: no cover
main()
main_wrapper()

0 comments on commit a65fa29

Please sign in to comment.