Created
September 27, 2017 11:50
-
-
Save Jipok/8e85c378da5616fec7d6d314754c65c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sets, strutils | |
if paramCount() != 2: | |
echo "mydiff file1 file2" | |
quit() | |
let file1 = open(paramStr(1)) | |
let file2 = open(paramStr(2)) | |
let old_lines = file1.readAll().splitLines() | |
let new_lines = file2.readAll().splitLines() | |
file1.close() | |
file2.close() | |
let old_lines_set = toSet(old_lines) | |
let new_lines_set = toSet(new_lines) | |
let old_added = old_lines_set - new_lines_set | |
let old_removed = new_lines_set - old_lines_set | |
for line in old_lines: | |
if line in old_added: | |
echo "-", line.strip() | |
elif line in old_removed: | |
echo "+", line.strip() | |
for line in new_lines: | |
if line in old_added: | |
echo "-", line.strip() | |
elif line in old_removed: | |
echo "+", line.strip() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment