@@ -165,6 +165,7 @@ static u32 setfg(u32 fg, enum ansi_color_mode m) {
165
165
* ESC[40m to ESC[47m set background color (100 to 107 for bright color)
166
166
* ESC[48;5;<n>m set 8 bits background color
167
167
* ESC[48;2;<r>,<g>,<b>m set 24 bits background color
168
+ * see https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
168
169
*/
169
170
static u32 setbg (u32 bg , enum ansi_color_mode m ) {
170
171
switch (m ) {
@@ -272,6 +273,13 @@ void twolines(const u32 *p, u16 width, int nosecondline, enum ansi_color_mode m)
272
273
#undef NOCOL
273
274
}
274
275
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
+
275
283
int main (int argc , char * * argv ) {
276
284
struct ngiflib_gif * gif ;
277
285
FILE * fgif ;
@@ -280,7 +288,10 @@ int main(int argc, char **argv) {
280
288
int i ;
281
289
282
290
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 ) {
284
295
/* last argument => filename */
285
296
input_file = argv [i ];
286
297
} else if (strcmp (argv [i ], "--tc" ) == 0 ) {
@@ -291,7 +302,8 @@ int main(int argc, char **argv) {
291
302
mode = BASIC ;
292
303
} else {
293
304
fprintf (stderr , "Unrecognized argument : \"%s\"\n" , argv [i ]);
294
- /* TODO : usage */
305
+ usage (stderr , argv [0 ]);
306
+ return 1 ;
295
307
}
296
308
}
297
309
0 commit comments