Skip to content

Commit bf8eb6d

Browse files
committed
gif2txt.c: usage
1 parent db19270 commit bf8eb6d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

gif2txt.c

+14-2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ static u32 setfg(u32 fg, enum ansi_color_mode m) {
165165
* ESC[40m to ESC[47m set background color (100 to 107 for bright color)
166166
* ESC[48;5;<n>m set 8 bits background color
167167
* ESC[48;2;<r>,<g>,<b>m set 24 bits background color
168+
* see https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
168169
*/
169170
static u32 setbg(u32 bg, enum ansi_color_mode m) {
170171
switch (m) {
@@ -272,6 +273,13 @@ void twolines(const u32 *p, u16 width, int nosecondline, enum ansi_color_mode m)
272273
#undef NOCOL
273274
}
274275

276+
static void usage(FILE * out, const char * argv0) {
277+
fprintf(out, "Usage: %s [--tc|--vga|--ansi] <file.gif>\n", argv0);
278+
fprintf(out, " --tc use 24 bits true colors\n");
279+
fprintf(out, " --vga use vga colors\n");
280+
fprintf(out, " --ansi use the standard 16 \"ANSI\" colors\n");
281+
}
282+
275283
int main(int argc, char **argv) {
276284
struct ngiflib_gif *gif;
277285
FILE *fgif;
@@ -280,7 +288,10 @@ int main(int argc, char **argv) {
280288
int i;
281289

282290
for (i = 1; i < argc; i++) {
283-
if (i == argc - 1) {
291+
if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
292+
usage(stdout, argv[0]);
293+
return 0;
294+
} else if (i == argc - 1) {
284295
/* last argument => filename */
285296
input_file = argv[i];
286297
} else if(strcmp(argv[i], "--tc") == 0) {
@@ -291,7 +302,8 @@ int main(int argc, char **argv) {
291302
mode = BASIC;
292303
} else {
293304
fprintf(stderr, "Unrecognized argument : \"%s\"\n", argv[i]);
294-
/* TODO : usage */
305+
usage(stderr, argv[0]);
306+
return 1;
295307
}
296308
}
297309

0 commit comments

Comments
 (0)