feat: add -h/--help with full option descriptions to fpack/funpack
This commit is contained in:
+21
-1
@@ -34,6 +34,7 @@ static struct option long_opts[] = {
|
||||
{"progress", no_argument, NULL, 'p'},
|
||||
{"quiet", no_argument, NULL, 'q'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -230,9 +231,25 @@ static int add_dir(struct fpk_writer *w, const char *dir, size_t base_len)
|
||||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: %s [-o output.fpk] [-p] [-q] [-v] input_dir\n", PROGRAM_NAME);
|
||||
fprintf(stderr, "try '%s --help' for more information\n", PROGRAM_NAME);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void help(void)
|
||||
{
|
||||
printf("usage: %s [options] input_dir\n", PROGRAM_NAME);
|
||||
printf("\n");
|
||||
printf("Pack a directory tree into an fpk archive.\n");
|
||||
printf("\n");
|
||||
printf("options:\n");
|
||||
printf(" -o, --output=FILE write the archive to FILE instead of the derived name\n");
|
||||
printf(" -p, --progress print packing progress\n");
|
||||
printf(" -q, --quiet suppress the final summary line\n");
|
||||
printf(" -v, --verbose print each packed entry\n");
|
||||
printf(" -h, --help show this help and exit\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *output_arg = NULL;
|
||||
@@ -242,7 +259,7 @@ int main(int argc, char **argv)
|
||||
struct fpk_writer *w;
|
||||
int c;
|
||||
|
||||
while ((c = getopt_long(argc, argv, "o:pqv", long_opts, NULL)) != -1) {
|
||||
while ((c = getopt_long(argc, argv, "o:pqvh", long_opts, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'o':
|
||||
output_arg = optarg;
|
||||
@@ -256,6 +273,9 @@ int main(int argc, char **argv)
|
||||
case 'v':
|
||||
flags |= FPACK_VERBOSE;
|
||||
break;
|
||||
case 'h':
|
||||
help();
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user