From 242e1dc5528474848c36ee68044b62f7da962241 Mon Sep 17 00:00:00 2001 From: Jacob Moody Date: Thu, 26 Dec 2024 03:54:31 +0000 Subject: [PATCH] vdiff: accept diff as filename argument and man page touch-up (thanks humm) --- sys/man/1/vdiff | 30 +++++++++++++++++++----------- sys/src/cmd/vdiff.c | 12 +++++++++++- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/sys/man/1/vdiff b/sys/man/1/vdiff index a00967ae2..cacad0f6a 100644 --- a/sys/man/1/vdiff +++ b/sys/man/1/vdiff @@ -8,37 +8,45 @@ vdiff \- a visual diff viewer ] [ .B -p -.I strip +.I nstrip +] +[ +.I file ] .SH DESCRIPTION .I vdiff -reads unified diff output from standard input and displays a colored version. Each file diff is displayed in a separate block that can be collapsed by a click on the file name. Right clicking on a line will send a +reads unified diff output from +.I file +or standard input and displays a colored version. +Each file within the diff is displayed in a separate block that can be collapsed by clicking on the file name. +Right clicking on a line will send a .IR plumb (6) message to the .B edit -port. Pressing +port. +Pressing .B q or .B del will exit -.B vdiff. +.I vdiff. .PP The -.B \-b +.B -b flag changes the color scheme to white text on a black background. .PP The -.B \-p -.I nstrip +.B -p flag removes .I nstrip -path elements from path before plumbing. +path elements from the path before plumbing. .SH EXAMPLE -% git/diff |vdiff +.EX +% git/diff | vdiff +.EE .SH SOURCE -/sys/src/cmd/vdiff.c +.B /sys/src/cmd/vdiff.c .SH SEE ALSO .IR diff (1) .SH HISTORY vdiff first appeared in 9front (January, 2024). - diff --git a/sys/src/cmd/vdiff.c b/sys/src/cmd/vdiff.c index b678aafce..d764fde29 100644 --- a/sys/src/cmd/vdiff.c +++ b/sys/src/cmd/vdiff.c @@ -585,7 +585,7 @@ parse(int fd) void usage(void) { - fprint(2, "%s [-b] [-p n]\n", argv0); + fprint(2, "usage: %s [-b] [-p nstrip] [file]\n", argv0); exits("usage"); } @@ -615,6 +615,16 @@ threadmain(int argc, char *argv[]) usage(); break; }ARGEND; + switch(argc){ + default: + usage(); + case 1: + close(0); + if(open(argv[0], OREAD) < 0) + sysfatal("open: %r"); + case 0: + break; + } parse(0); if(nblocks==1 && blocks[0]->nlines==0){