Changeset 2601


Ignore:
Timestamp:
Jul 29, 2008, 1:01:14 AM (12 years ago)
Author:
Sam Hocevar
Message:
  • Improve genethumb --help message.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/genethumb/genethumb.c

    r2264 r2601  
    2121#endif
    2222
     23#define DEFAULT_WIDTH 120
     24#define DEFAULT_HEIGHT 90
     25
    2326#define MOREINFO "Try `%s --help' for more information.\n"
     27
     28static void usage(void);
    2429
    2530int main(int argc, char *argv[])
     
    2833    pipi_image_t *src, *dst;
    2934
    30     int i, w = 0, h = 0, bpp = 24;
     35    int i, w = DEFAULT_WIDTH, h = DEFAULT_HEIGHT, bpp = 24;
    3136
    3237    for(;;)
     
    3540        static struct myoption long_options[] =
    3641        {
     42            { "bpp",         1, NULL, 'b' },
    3743            { "geometry",    1, NULL, 'g' },
    38             { "bpp",         1, NULL, 'b' },
     44            { "help",        0, NULL, 'h' },
     45            { NULL,          0, NULL, 0   },
    3946        };
    40         int c = mygetopt(argc, argv, "g:b:", long_options, &option_index);
     47        int c = mygetopt(argc, argv, "b:g:h", long_options, &option_index);
    4148
    4249        if(c == -1)
     
    5865                h = atoi(strchr(myoptarg, 'x') + 1);
    5966            break;
     67        case 'h':
     68            usage();
     69            return EXIT_SUCCESS;
    6070        default:
    6171            fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
     
    97107}
    98108
     109static void usage(void)
     110{
     111    printf("Usage: genethumb [-b bpp] [-g geometry] SOURCE DESTINATION\n");
     112    printf("       genethumb -h | --help\n");
     113    printf("Create an image thumbnail.\n");
     114    printf("\n");
     115    printf("Mandatory arguments to long options are mandatory for short options too.\n");
     116    printf("  -b, --bpp <bits>          bits per pixel (32 or 16)\n");
     117    printf("  -g, --geometry <geometry> target geometry (default %ix%i)\n",
     118           DEFAULT_WIDTH, DEFAULT_HEIGHT);
     119    printf("  -h, --help                display this help and exit\n");
     120    printf("\n");
     121    printf("Written by Sam Hocevar. Report bugs to <sam@zoy.org>.\n");
     122}
     123
Note: See TracChangeset for help on using the changeset viewer.