From f9bd5e6a7b0b9461b3ab68d08e2bd9404f2f5078 Mon Sep 17 00:00:00 2001 From: Jack Foltz Date: Sun, 9 Dec 2018 00:46:03 -0500 Subject: [PATCH] Add diff option --- install.py | 4 +++- lib/diff.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 lib/diff.py diff --git a/install.py b/install.py index 7c7e15a..04b1702 100755 --- a/install.py +++ b/install.py @@ -65,7 +65,9 @@ if __name__ == '__main__': ('-e', '--enable-units', deploy.enable_units, 'enable package units'), ('-C', '--import-config', deploy.import_config, 'import package config'), ('-U', '--import-units', deploy.import_units, 'import package units'), - ('-l', '--dump', dump, 'dump package attributes') + ('-l', '--dump', dump, 'dump package attributes'), + ('-Dc', '--diff-config', deploy.diff_config, 'diff local and repo config'), + ('-Du', '--diff-units', deploy.diff_units, 'diff local and repo units') ] for action in actions: diff --git a/lib/diff.py b/lib/diff.py new file mode 100644 index 0000000..f44b6fd --- /dev/null +++ b/lib/diff.py @@ -0,0 +1,11 @@ +import lib.proc as proc + +def diff(file1, file2): + cmd = ['diff', '-r', str(file1.resolve()), str(file2.expanduser())] + subproc = proc.exec(cmd) + + delta = proc.communicate(subproc, cmd, [0, 1]) + + ret = str(file1) + ' vs ' + str(file2) + ': ' + ret += delta if delta != '' else 'Files are identical.' + return ret