vdiff: accept diff as filename argument and man page touch-up (thanks humm)

This commit is contained in:
Jacob Moody 2024-12-26 03:54:31 +00:00
parent ed318aac59
commit 242e1dc552
2 changed files with 30 additions and 12 deletions

View file

@ -8,37 +8,45 @@ vdiff \- a visual diff viewer
] ]
[ [
.B -p .B -p
.I strip .I nstrip
]
[
.I file
] ]
.SH DESCRIPTION .SH DESCRIPTION
.I vdiff .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) .IR plumb (6)
message to the message to the
.B edit .B edit
port. Pressing port.
Pressing
.B q .B q
or or
.B del .B del
will exit will exit
.B vdiff. .I vdiff.
.PP .PP
The The
.B \-b .B -b
flag changes the color scheme to white text on a black background. flag changes the color scheme to white text on a black background.
.PP .PP
The The
.B \-p .B -p
.I nstrip
flag removes flag removes
.I nstrip .I nstrip
path elements from path before plumbing. path elements from the path before plumbing.
.SH EXAMPLE .SH EXAMPLE
% git/diff |vdiff .EX
% git/diff | vdiff
.EE
.SH SOURCE .SH SOURCE
/sys/src/cmd/vdiff.c .B /sys/src/cmd/vdiff.c
.SH SEE ALSO .SH SEE ALSO
.IR diff (1) .IR diff (1)
.SH HISTORY .SH HISTORY
vdiff first appeared in 9front (January, 2024). vdiff first appeared in 9front (January, 2024).

View file

@ -585,7 +585,7 @@ parse(int fd)
void void
usage(void) usage(void)
{ {
fprint(2, "%s [-b] [-p n]\n", argv0); fprint(2, "usage: %s [-b] [-p nstrip] [file]\n", argv0);
exits("usage"); exits("usage");
} }
@ -615,6 +615,16 @@ threadmain(int argc, char *argv[])
usage(); usage();
break; break;
}ARGEND; }ARGEND;
switch(argc){
default:
usage();
case 1:
close(0);
if(open(argv[0], OREAD) < 0)
sysfatal("open: %r");
case 0:
break;
}
parse(0); parse(0);
if(nblocks==1 && blocks[0]->nlines==0){ if(nblocks==1 && blocks[0]->nlines==0){