redo-whichdo: updated output format.

The new format is just a list of .do files we tried, with a newline
after each one.  If we successfully found a .do file, we exit 0, else
we exit 1.

As discussed on the redo-list mailing list, it's easier to parse
without the extra cruft.  This makes users figure out $1 and $2
themselves, but that's not very hard, and maybe for the best.
This commit is contained in:
Avery Pennarun 2018-10-30 23:21:37 -04:00
commit f835becde4
2 changed files with 54 additions and 63 deletions

View file

@ -12,18 +12,13 @@ if len(sys.argv[1:]) != 1:
sys.exit(1)
want = sys.argv[1]
for dodir,dofile,basedir,basename,ext in builder.possible_do_files(os.path.abspath(want)):
abswant = os.path.abspath(want)
for dodir,dofile,basedir,basename,ext in builder.possible_do_files(abswant):
dopath = os.path.join('/', dodir, dofile)
relpath = os.path.relpath(dopath, '.')
exists = os.path.exists(dopath)
assert('\n' not in relpath)
print relpath
if exists:
print '+', relpath
assert('\n' not in basename)
assert('\n' not in ext)
print '1', basename+ext
print '2', basename
sys.exit(0)
else:
print '-', relpath
sys.exit(0)
sys.exit(1) # no appropriate dofile found