1
0
mirror of https://github.com/Foltik/dotfiles synced 2024-11-24 04:22:50 -05:00

Add diff option

This commit is contained in:
Jack Foltz 2018-12-09 00:46:03 -05:00
parent 1d42aab37e
commit f9bd5e6a7b
Signed by: foltik
GPG Key ID: D1F0331758D1F29A
2 changed files with 14 additions and 1 deletions

View File

@ -65,7 +65,9 @@ if __name__ == '__main__':
('-e', '--enable-units', deploy.enable_units, 'enable package units'), ('-e', '--enable-units', deploy.enable_units, 'enable package units'),
('-C', '--import-config', deploy.import_config, 'import package config'), ('-C', '--import-config', deploy.import_config, 'import package config'),
('-U', '--import-units', deploy.import_units, 'import package units'), ('-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: for action in actions:

11
lib/diff.py Normal file
View File

@ -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