1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#!/usr/bin/env python
import argparse
import sys
import snapdiff
def main(argv):
description = 'Diff two repos with different urls'
parser = argparse.ArgumentParser(description=description)
parser.add_argument(dest='old', help='old repo')
parser.add_argument(dest='new', help='new repo')
parser.add_argument('--json', help='output json diffs', action='store_true')
group = parser.add_mutually_exclusive_group()
group.add_argument('-t', dest='type', default='repo', help="which diff you want(repo | image, default is repo)")
group.add_argument('-d', dest='directory', help="Output html diffs into the directory")
args = parser.parse_args(argv)
if args.directory:
snapdiff.diff_to_dist(args.old, args.new, args.directory, style=args.type or 'repo')
print "Diff between '%s' and '%s' has been ready in %s" % (args.old, args.new, args.directory)
elif args.json:
print snapdiff.diff_to_JSON(args.old, args.new, style=args.type)
else:
print snapdiff.diff_to_HTML(args.old, args.new, style=args.type)
if __name__ == '__main__':
try:
sys.exit(main(sys.argv[1:]))
except KeyboardInterrupt:
pass
|