From 618e56b2a5f9b2cb381ea805e811cf1f8d76b1f8 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Mon, 10 Jul 2017 10:13:57 -0700 Subject: [PATCH] Display result of config upgrade. --- borgmatic/commands/convert_config.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/borgmatic/commands/convert_config.py b/borgmatic/commands/convert_config.py index 2b99863..eb97ec4 100644 --- a/borgmatic/commands/convert_config.py +++ b/borgmatic/commands/convert_config.py @@ -3,6 +3,7 @@ from argparse import ArgumentParser import os from subprocess import CalledProcessError import sys +import textwrap from ruamel import yaml @@ -48,6 +49,30 @@ def parse_arguments(*arguments): return parser.parse_args(arguments) +TEXT_WRAP_CHARACTERS = 80 + + +def display_result(args): # pragma: no cover + result_lines = textwrap.wrap( + 'Your borgmatic configuration has been upgraded. Please review the result in {}.'.format( + args.destination_config_filename + ), + TEXT_WRAP_CHARACTERS, + ) + + delete_lines = textwrap.wrap( + 'Once you are satisfied, you can safely delete {}{}.'.format( + args.source_config_filename, + ' and {}'.format(args.source_excludes_filename) if args.source_excludes_filename else '', + ), + TEXT_WRAP_CHARACTERS, + ) + + print('\n'.join(result_lines)) + print() + print('\n'.join(delete_lines)) + + def main(): # pragma: no cover try: args = parse_arguments(*sys.argv[1:]) @@ -65,6 +90,8 @@ def main(): # pragma: no cover # TODO: As a backstop, check that the written config can actually be read and parsed, and # that it matches the destination config data structure that was written. + + display_result(args) except (ValueError, OSError) as error: print(error, file=sys.stderr) sys.exit(1)