From bfe5b576a2bf2e26a4bdeec9ef12a354537ac965 Mon Sep 17 00:00:00 2001 From: Serpent7776 Date: Tue, 26 Aug 2025 21:10:13 +0200 Subject: [PATCH] Add --skipmissing flag This skips files that do not have a matching file in the other directory. --- vimtabdiff.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/vimtabdiff.py b/vimtabdiff.py index 02550fc..9c32d0b 100755 --- a/vimtabdiff.py +++ b/vimtabdiff.py @@ -32,6 +32,9 @@ def parse_args() -> argparse.Namespace: parser.add_argument( "--onlydiffs", help="only open files where there is a diff", action="store_true" ) + parser.add_argument( + "--skipmissing", help="skip non-existent files", action="store_true" + ) return parser.parse_args() @@ -87,9 +90,10 @@ def main() -> None: aPath = a.resolve() if a else os.devnull bPath = b.resolve() if b else os.devnull if ( - args.onlydiffs - and a and b - and open(aPath, mode="rb").read() == open(bPath, mode="rb").read() + (args.skipmissing and (not a or not b)) or + (args.onlydiffs + and a and b + and open(aPath, mode="rb").read() == open(bPath, mode="rb").read()) ): continue print(f"tabedit {aPath} | vsp {bPath}", file=vimCmdFile)