mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2024-11-23 21:33:07 +01:00
Add -d option for debug messages
This commit is contained in:
parent
83af722da2
commit
930535cbea
@ -9,6 +9,7 @@ ctpv \- terminal previewer
|
||||
.SH SYNOPSIS
|
||||
.
|
||||
.SY ctpv
|
||||
.RI [ \-d ]
|
||||
.I file
|
||||
.RI [ w ]
|
||||
.RI [ h ]
|
||||
@ -282,6 +283,10 @@ command to server with ID
|
||||
Kill server with ID
|
||||
.IR id .
|
||||
.
|
||||
.TP
|
||||
.B \-d
|
||||
Enable debug messages.
|
||||
.
|
||||
.SH CONFIGURATION
|
||||
.
|
||||
.B ctpv
|
||||
|
@ -411,9 +411,10 @@ int main(int argc, char *argv[])
|
||||
program = argc > 0 ? argv[0] : "ctpv";
|
||||
|
||||
ctpv.opts.shell = "/bin/sh";
|
||||
ctpv.debug = 0;
|
||||
|
||||
int c;
|
||||
while ((c = getopt(argc, argv, "hs:c:e:lmv")) != -1) {
|
||||
while ((c = getopt(argc, argv, "hs:c:e:lmdv")) != -1) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
ctpv.mode = MODE_HELP;
|
||||
@ -436,6 +437,9 @@ int main(int argc, char *argv[])
|
||||
case 'm':
|
||||
ctpv.mode = MODE_MIME;
|
||||
break;
|
||||
case 'd':
|
||||
ctpv.debug = 1;
|
||||
break;
|
||||
case 'v':
|
||||
ctpv.mode = MODE_VERSION;
|
||||
break;
|
||||
|
@ -20,6 +20,7 @@ struct CTPV {
|
||||
int autochafa, chafasixel, showgpg;
|
||||
char *shell;
|
||||
} opts;
|
||||
int debug;
|
||||
};
|
||||
|
||||
extern struct CTPV ctpv;
|
||||
|
@ -201,10 +201,15 @@ run:
|
||||
return ERR;
|
||||
}
|
||||
|
||||
if (ctpv.debug)
|
||||
fprintf(stderr, "Running preview: %s\n", p->name);
|
||||
|
||||
ERRCHK_RET_OK(run(p, &exitcode, &signal));
|
||||
|
||||
switch (exitcode) {
|
||||
case FAILED_PREVIEW_EC:
|
||||
if (ctpv.debug)
|
||||
fprintf(stderr, "Preview %s failed\n", p->name);
|
||||
i++;
|
||||
goto run;
|
||||
case ENOUGH_READ_EC:
|
||||
|
Loading…
Reference in New Issue
Block a user