| 82 | # return false iff a problem |
| 83 | |
| 84 | def main(args): |
| 85 | import getopt |
| 86 | try: |
| 87 | opts, args = getopt.getopt(args, "qr:") |
| 88 | except getopt.error as detail: |
| 89 | return fail(str(detail)) |
| 90 | noisy = 1 |
| 91 | qseen = rseen = 0 |
| 92 | for opt, val in opts: |
| 93 | if opt == "-q": |
| 94 | qseen = 1 |
| 95 | noisy = 0 |
| 96 | elif opt == "-r": |
| 97 | rseen = 1 |
| 98 | whichfile = val |
| 99 | if qseen and rseen: |
| 100 | return fail("can't specify both -q and -r") |
| 101 | if rseen: |
| 102 | if args: |
| 103 | return fail("no args allowed with -r option") |
| 104 | if whichfile in ("1", "2"): |
| 105 | restore(whichfile) |
| 106 | return 1 |
| 107 | return fail("-r value must be 1 or 2") |
| 108 | if len(args) != 2: |
| 109 | return fail("need 2 filename args") |
| 110 | f1name, f2name = args |
| 111 | if noisy: |
| 112 | print('-:', f1name) |
| 113 | print('+:', f2name) |
| 114 | return fcompare(f1name, f2name) |
| 115 | |
| 116 | # read ndiff output from stdin, and print file1 (which=='1') or |
| 117 | # file2 (which=='2') to stdout |