Changeset 1319
- Timestamp:
- Nov 10, 2006, 8:47:17 AM (16 years ago)
- Location:
- toilet/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
toilet/trunk/src/filter.c
r1317 r1319 40 40 char const *name; 41 41 void (*function)(context_t *); 42 char const *description; 42 43 } 43 44 const lookup[] = 44 45 { 45 { "crop", filter_crop },46 { "gay", filter_gay },47 { "metal", filter_metal },48 { "flip", filter_flip },49 { "flop", filter_flop },50 { "rotate", filter_rotate },46 { "crop", filter_crop, "crop unused blanks" }, 47 { "gay", filter_gay, "add a rainbow colour effect" }, 48 { "metal", filter_metal, "add a metallic colour effect" }, 49 { "flip", filter_flip, "flip horizontally" }, 50 { "flop", filter_flop, "flip vertically" }, 51 { "rotate", filter_rotate, "perform a 180 degrees rotation" }, 51 52 }; 53 54 int filter_list(void) 55 { 56 int i; 57 58 fprintf(stderr, "Available filters:\n"); 59 for(i = 0; i < sizeof(lookup) / sizeof(lookup[0]); i++) 60 fprintf(stderr, "\"%s\": %s\n", lookup[i].name, lookup[i].description); 61 62 return 0; 63 } 52 64 53 65 int filter_add(context_t *cx, char const *filter) -
toilet/trunk/src/filter.h
r1241 r1319 16 16 */ 17 17 18 extern int filter_list(void); 18 19 extern int filter_add(context_t *, char const *); 19 20 extern int filter_do(context_t *); -
toilet/trunk/src/main.c
r1293 r1319 29 29 #include <stdio.h> 30 30 #include <stdlib.h> 31 #include <string.h> 31 32 #include <cucul.h> 32 33 … … 39 40 static void usage(void); 40 41 #endif 42 static int export_list(void); 41 43 42 44 int main(int argc, char *argv[]) … … 72 74 { "gay", 0, NULL, 130 }, 73 75 { "metal", 0, NULL, 131 }, 76 { "export", 1, NULL, 'E' }, 74 77 { "irc", 0, NULL, 140 }, 75 78 { "html", 0, NULL, 141 }, 76 { "tga", 0, NULL, 142 },77 79 { "help", 0, NULL, 'h' }, 78 80 { "infocode", 1, NULL, 'I' }, … … 81 83 }; 82 84 83 int c = getopt_long(argc, argv, "f:d:w:tF: hI:v",85 int c = getopt_long(argc, argv, "f:d:w:tF:E:hI:v", 84 86 long_options, &option_index); 85 87 # else 86 88 # define MOREINFO "Try `%s -h' for more information.\n" 87 int c = getopt(argc, argv, "f:d:w:tF: hI:v");89 int c = getopt(argc, argv, "f:d:w:tF:E:hI:v"); 88 90 # endif 89 91 if(c == -1) … … 108 110 break; 109 111 case 'F': /* --filter */ 110 if(filter_add(cx, optarg)) 112 if(!strcmp(optarg, "list")) 113 return filter_list(); 114 if(filter_add(cx, optarg) < 0) 111 115 return -1; 112 116 break; … … 132 136 break; 133 137 } 138 case 'E': /* --export */ 139 if(!strcmp(optarg, "list")) 140 return export_list(); 141 cx->export = optarg; 142 break; 134 143 case 140: /* --irc */ 135 144 cx->export = "irc"; … … 137 146 case 141: /* --html */ 138 147 cx->export = "html"; 139 break;140 case 142: /* --tga */141 cx->export = "tga";142 148 break; 143 149 case '?': … … 196 202 "Usage: toilet [ -htv ] [ -d fontdirectory ]\n" \ 197 203 " [ -f fontfile ] [ -F filter ] [ -w outputwidth ]\n" \ 198 " [ -I infocode ] [ message ]\n"204 " [ -I infocode ] [ -E format ] [ message ]\n" 199 205 #else 200 206 # define USAGE "" … … 228 234 printf(" -w, --width <width> set output width\n"); 229 235 printf(" -t, --termwidth adapt to terminal's width\n"); 230 printf(" -F, --filter <name> apply one or several filters to the text\n"); 236 printf(" -F, --filter <filters> apply one or several filters to the text\n"); 237 printf(" -F, --filter list list available filters\n"); 231 238 printf(" --gay rainbow filter (same as -F gay)\n"); 232 239 printf(" --metal metal filter (same as -F metal)\n"); 233 printf(" --irc output IRC colour codes\n"); 234 printf(" --html output an HTML document\n"); 235 printf(" --tga output a TGA image\n"); 240 printf(" -E, --export <format> select export format\n"); 241 printf(" -E, --export list list available export formats\n"); 242 printf(" --irc output IRC colour codes (same as -E irc)\n"); 243 printf(" --html output an HTML document (same as -E html)\n"); 236 244 printf(" -h, --help display this help and exit\n"); 237 245 printf(" -I, --infocode <code> print FIGlet-compatible infocode\n"); … … 242 250 printf(" -w <width> set output width\n"); 243 251 printf(" -t adapt to terminal's width\n"); 244 printf(" -F <name> apply one or several filters to the text\n"); 252 printf(" -F <filters> apply one or several filters to the text\n"); 253 printf(" -F list list available filters\n"); 254 printf(" -E <format> select export format\n"); 255 printf(" -E list list available export formats\n"); 245 256 printf(" -h display this help and exit\n"); 246 257 printf(" -I <code> print FIGlet-compatible infocode\n"); … … 250 261 #endif 251 262 263 static int export_list(void) 264 { 265 char const * const * exports, * const * p; 266 267 exports = cucul_get_export_list(); 268 269 printf("Available export formats:\n"); 270 for(p = exports; *p; p += 2) 271 printf("\"%s\": %s\n", *p, *(p + 1)); 272 273 return 0; 274 } 275
Note: See TracChangeset
for help on using the changeset viewer.