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
.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
.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).

View file

@ -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){