Commit aad1d701 authored by conrad's avatar conrad

add -? option to all tools, which simply prints out all possible

options, and nothing else (for shell completion).


git-svn-id: http://svn.annodex.net/liboggz/trunk@3674 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 269b0182
...@@ -251,6 +251,11 @@ main (int argc, char ** argv) ...@@ -251,6 +251,11 @@ main (int argc, char ** argv)
return (1); return (1);
} }
if (!strncmp (argv[1], "-?", 2)) {
printf ("-h --help\n");
exit (0);
}
if (!strcmp (argv[1], "-h") || !strcmp (argv[1], "--help")) { if (!strcmp (argv[1], "-h") || !strcmp (argv[1], "--help")) {
usage (progname); usage (progname);
return (0); return (0);
......
...@@ -38,6 +38,20 @@ cmd_main (OCState * state, int argc, char * argv[]) ...@@ -38,6 +38,20 @@ cmd_main (OCState * state, int argc, char * argv[])
int show_help = 0; int show_help = 0;
int i; int i;
char * optstring = "s:e:o:khv";
#ifdef HAVE_GETOPT_LONG
static struct option long_options[] = {
{"start", required_argument, 0, 's'},
{"end", required_argument, 0, 'e'},
{"output", required_argument, 0, 'o'},
{"no-skeleton", no_argument, 0, 'k'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{0,0,0,0}
};
#endif
progname = argv[0]; progname = argv[0];
if (argc < 2) { if (argc < 2) {
...@@ -45,24 +59,21 @@ cmd_main (OCState * state, int argc, char * argv[]) ...@@ -45,24 +59,21 @@ cmd_main (OCState * state, int argc, char * argv[])
return (1); return (1);
} }
if (!strncmp (argv[1], "-?", 2)) {
#ifdef HAVE_GETOPT_LONG
ot_print_options (long_options, optstring);
#else
ot_print_short_options (optstring);
#endif
exit (0);
}
memset (state, 0, sizeof(*state)); memset (state, 0, sizeof(*state));
state->end = -1.0; state->end = -1.0;
state->do_skeleton = 1; state->do_skeleton = 1;
while (1) { while (1) {
char * optstring = "s:e:o:khv";
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
static struct option long_options[] = {
{"start", required_argument, 0, 's'},
{"end", required_argument, 0, 'e'},
{"output", required_argument, 0, 'o'},
{"no-skeleton", no_argument, 0, 'k'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{0,0,0,0}
};
i = getopt_long(argc, argv, optstring, long_options, NULL); i = getopt_long(argc, argv, optstring, long_options, NULL);
#else #else
i = getopt (argc, argv, optstring); i = getopt (argc, argv, optstring);
......
...@@ -386,10 +386,35 @@ main (int argc, char ** argv) ...@@ -386,10 +386,35 @@ main (int argc, char ** argv)
long n; long n;
int i = 1; int i = 1;
char * optstring = "lo:dac:s:hv";
#ifdef HAVE_GETOPT_LONG
static struct option long_options[] = {
{"list", no_argument, 0, 'l'},
{"output", required_argument, 0, 'o'},
{"delete", no_argument, 0, 'd'},
{"all", no_argument, 0, 'a'},
{"content-type", required_argument, 0, 'c'},
{"serialno", required_argument, 0, 's'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{0,0,0,0}
};
#endif
ot_init (); ot_init ();
progname = argv[0]; progname = argv[0];
if (argc == 2 && !strncmp (argv[1], "-?", 2)) {
#ifdef HAVE_GETOPT_LONG
ot_print_options (long_options, optstring);
#else
ot_print_short_options (optstring);
#endif
exit (0);
}
if (argc < 3) { if (argc < 3) {
usage (progname); usage (progname);
return (1); return (1);
...@@ -398,21 +423,7 @@ main (int argc, char ** argv) ...@@ -398,21 +423,7 @@ main (int argc, char ** argv)
ocdata = ocdata_new (); ocdata = ocdata_new ();
while (1) { while (1) {
char * optstring = "lo:dac:s:hv";
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
static struct option long_options[] = {
{"list", no_argument, 0, 'l'},
{"output", required_argument, 0, 'o'},
{"delete", no_argument, 0, 'd'},
{"all", no_argument, 0, 'a'},
{"content-type", required_argument, 0, 'c'},
{"serialno", required_argument, 0, 's'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{0,0,0,0}
};
i = getopt_long(argc, argv, optstring, long_options, NULL); i = getopt_long(argc, argv, optstring, long_options, NULL);
#else #else
i = getopt (argc, argv, optstring); i = getopt (argc, argv, optstring);
......
...@@ -59,13 +59,26 @@ usage () { ...@@ -59,13 +59,26 @@ usage () {
GETOPTEST=`getopt --version` GETOPTEST=`getopt --version`
case $GETOPTEST in case $GETOPTEST in
getopt*) # GNU getopt getopt*) # GNU getopt
TEMP=`getopt -l verbose -l version -l brief -l context:: -l unified:: -l ed -l normal -l rcs -l side-by-side -l paginate -l binary -l hexadecimal -l serialno: -l content-type: -l hide-offset -l hide-serialno -l hide-granulepos -l hide-packetno -l help -- +qC:uU:eylbxs:c:OSGPhv "$@"` GETOPTARGS="-l verbose -l version -l brief -l context:: -l unified:: -l ed -l normal -l rcs -l side-by-side -l paginate -l binary -l hexadecimal -l serialno: -l content-type: -l hide-offset -l hide-serialno -l hide-granulepos -l hide-packetno -l help -- +qC:uU:eylbxs:c:OSGPhv"
QARGS="--verbose --version --brief --context --unified --ed --normal --rcs --side-by-side --paginate --binary --hexadecimal --serialno --content-type --hide-offset --hide-serialno --hide-granulepos --hide-packetno --help -q -C -u -U -e -y -l -b -x -s -c -O -S -G -P -h -v"
;; ;;
*) # POSIX getopt ? *) # POSIX getopt ?
TEMP=`getopt qC:uU:eylbxs:c:OSGPhv "$@"` GETOPTARGS="qC:uU:eylbxs:c:OSGPhv"
QARGS="-q -C -u -U -e -y -l -b -x -s -c -O -S -G -P -h -v"
;; ;;
esac esac
# First check for -? option
if test "X$1" = "X-?"; then
echo $QARGS
exit 0
fi
echo $GETOPTARGS
TEMP=`getopt $GETOPTARGS "$@"`
echo $TEMP
if test "$?" != "0"; then if test "$?" != "0"; then
usage usage
fi fi
......
...@@ -505,6 +505,27 @@ main (int argc, char ** argv) ...@@ -505,6 +505,27 @@ main (int argc, char ** argv)
int filter_serialnos = 0; int filter_serialnos = 0;
int filter_content_types = 0; int filter_content_types = 0;
char * optstring = "hvbxnro:s:c:OSGP";
#ifdef HAVE_GETOPT_LONG
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{"binary", no_argument, 0, 'b'},
{"hexadecimal", no_argument, 0, 'x'},
{"new", no_argument, 0, 'n'},
{"revert", no_argument, 0, 'r'},
{"output", required_argument, 0, 'o'},
{"serialno", required_argument, 0, 's'},
{"content-type", required_argument, 0, 'c'},
{"hide-offset", no_argument, 0, 'O'},
{"hide-serialno", no_argument, 0, 'S'},
{"hide-granulepos", no_argument, 0, 'G'},
{"hide-packetno", no_argument, 0, 'P'},
{0,0,0,0}
};
#endif
ot_init (); ot_init ();
progname = argv[0]; progname = argv[0];
...@@ -514,31 +535,21 @@ main (int argc, char ** argv) ...@@ -514,31 +535,21 @@ main (int argc, char ** argv)
return (1); return (1);
} }
if (!strncmp (argv[1], "-?", 2)) {
#ifdef HAVE_GETOPT_LONG
ot_print_options (long_options, optstring);
#else
ot_print_short_options (optstring);
#endif
exit (0);
}
oddata = oddata_new (); oddata = oddata_new ();
oddata->read_packet = read_packet; oddata->read_packet = read_packet;
while (1) { while (1) {
char * optstring = "hvbxnro:s:c:OSGP";
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{"binary", no_argument, 0, 'b'},
{"hexadecimal", no_argument, 0, 'x'},
{"new", no_argument, 0, 'n'},
{"revert", no_argument, 0, 'r'},
{"output", required_argument, 0, 'o'},
{"serialno", required_argument, 0, 's'},
{"content-type", required_argument, 0, 'c'},
{"hide-offset", no_argument, 0, 'O'},
{"hide-serialno", no_argument, 0, 'S'},
{"hide-granulepos", no_argument, 0, 'G'},
{"hide-packetno", no_argument, 0, 'P'},
{0,0,0,0}
};
i = getopt_long(argc, argv, optstring, long_options, NULL); i = getopt_long(argc, argv, optstring, long_options, NULL);
#else #else
i = getopt (argc, argv, optstring); i = getopt (argc, argv, optstring);
......
...@@ -516,6 +516,22 @@ main (int argc, char ** argv) ...@@ -516,6 +516,22 @@ main (int argc, char ** argv)
OGGZ * oggz; OGGZ * oggz;
OI_Info info; OI_Info info;
char * optstring = "hvlbgpka";
#ifdef HAVE_GETOPT_LONG
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{"length", no_argument, 0, 'l'},
{"bitrate", no_argument, 0, 'b'},
{"page-stats", no_argument, 0, 'g'},
{"packet-stats", no_argument, 0, 'p'},
{"skeleton", no_argument, 0, 'k'},
{"all", no_argument, 0, 'a'},
{NULL,0,0,0}
};
#endif
progname = argv[0]; progname = argv[0];
if (argc < 2) { if (argc < 2) {
...@@ -523,22 +539,17 @@ main (int argc, char ** argv) ...@@ -523,22 +539,17 @@ main (int argc, char ** argv)
return (1); return (1);
} }
while (1) { if (!strncmp (argv[1], "-?", 2)) {
char * optstring = "hvlbgpka";
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
static struct option long_options[] = { ot_print_options (long_options, optstring);
{"help", no_argument, 0, 'h'}, #else
{"version", no_argument, 0, 'v'}, ot_print_short_options (optstring);
{"length", no_argument, 0, 'l'}, #endif
{"bitrate", no_argument, 0, 'b'}, exit (0);
{"page-stats", no_argument, 0, 'g'}, }
{"packet-stats", no_argument, 0, 'p'},
{"skeleton", no_argument, 0, 'k'},
{"all", no_argument, 0, 'a'},
{0,0,0,0}
};
while (1) {
#ifdef HAVE_GETOPT_LONG
i = getopt_long (argc, argv, optstring, long_options, NULL); i = getopt_long (argc, argv, optstring, long_options, NULL);
#else #else
i = getopt (argc, argv, optstring); i = getopt (argc, argv, optstring);
......
...@@ -78,7 +78,10 @@ main (int argc, char ** argv) ...@@ -78,7 +78,10 @@ main (int argc, char ** argv)
char * progname = argv[0]; char * progname = argv[0];
if (argc == 2) { if (argc == 2) {
if (!strncmp (argv[1], "-v", 2) || !strncmp (argv[1], "--version", 9)) { if (!strncmp (argv[1], "-?", 2)) {
printf ("-v --version -h --help\n");
exit (0);
} else if (!strncmp (argv[1], "-v", 2) || !strncmp (argv[1], "--version", 9)) {
printf ("%s version " VERSION "\n", progname); printf ("%s version " VERSION "\n", progname);
exit (0); exit (0);
} else if (!strncmp (argv[1], "-h", 2) || !strncmp (argv[1], "--help", 6)) { } else if (!strncmp (argv[1], "-h", 2) || !strncmp (argv[1], "--help", 6)) {
......
...@@ -331,6 +331,18 @@ main (int argc, char * argv[]) ...@@ -331,6 +331,18 @@ main (int argc, char * argv[])
OMData * omdata; OMData * omdata;
int i; int i;
char * optstring = "hvVo:";
#ifdef HAVE_GETOPT_LONG
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{"verbose", no_argument, 0, 'V'},
{"output", required_argument, 0, 'o'},
{0,0,0,0}
};
#endif
ot_init (); ot_init ();
progname = argv[0]; progname = argv[0];
...@@ -340,20 +352,19 @@ main (int argc, char * argv[]) ...@@ -340,20 +352,19 @@ main (int argc, char * argv[])
return (1); return (1);
} }
if (!strncmp (argv[1], "-?", 2)) {
#ifdef HAVE_GETOPT_LONG
ot_print_options (long_options, optstring);
#else
ot_print_short_options (optstring);
#endif
exit (0);
}
omdata = omdata_new(); omdata = omdata_new();
while (1) { while (1) {
char * optstring = "hvVo:";
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{"verbose", no_argument, 0, 'V'},
{"output", required_argument, 0, 'o'},
{0,0,0,0}
};
i = getopt_long (argc, argv, optstring, long_options, NULL); i = getopt_long (argc, argv, optstring, long_options, NULL);
#else #else
i = getopt (argc, argv, optstring); i = getopt (argc, argv, optstring);
......
...@@ -306,6 +306,21 @@ main (int argc, char * argv[]) ...@@ -306,6 +306,21 @@ main (int argc, char * argv[])
long l; long l;
int i, n; int i, n;
char * optstring = "hvVo:s:i:c:";
#ifdef HAVE_GETOPT_LONG
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{"output", required_argument, 0, 'o'},
{"verbose", no_argument, 0, 'V'},
{"serialno", required_argument, 0, 's'},
{"stream-index", required_argument, 0, 'i'},
{"content-type", required_argument, 0, 'c'},
{0,0,0,0}
};
#endif
ot_init(); ot_init();
progname = argv[0]; progname = argv[0];
...@@ -315,23 +330,19 @@ main (int argc, char * argv[]) ...@@ -315,23 +330,19 @@ main (int argc, char * argv[])
return (1); return (1);
} }
if (!strncmp (argv[1], "-?", 2)) {
#ifdef HAVE_GETOPT_LONG
ot_print_options (long_options, optstring);
#else
ot_print_short_options (optstring);
#endif
exit (0);
}
ordata = ordata_new (); ordata = ordata_new ();
while (1) { while (1) {
char * optstring = "hvVo:s:i:c:";
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{"output", required_argument, 0, 'o'},
{"verbose", no_argument, 0, 'V'},
{"serialno", required_argument, 0, 's'},
{"stream-index", required_argument, 0, 'i'},
{"content-type", required_argument, 0, 'c'},
{0,0,0,0}
};
i = getopt_long (argc, argv, optstring, long_options, NULL); i = getopt_long (argc, argv, optstring, long_options, NULL);
#else #else
i = getopt (argc, argv, optstring); i = getopt (argc, argv, optstring);
......
...@@ -207,6 +207,19 @@ main (int argc, char ** argv) ...@@ -207,6 +207,19 @@ main (int argc, char ** argv)
char * infilename = NULL, * outfilename = NULL; char * infilename = NULL, * outfilename = NULL;
int i; int i;
char * optstring = "f:khvo:";
#ifdef HAVE_GETOPT_LONG
static struct option long_options[] = {
{"output", required_argument, 0, 'o'},
{"format", required_argument, 0, 'f'},
{"keyframe", no_argument, 0, 'k'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{0,0,0,0}
};
#endif
progname = argv[0]; progname = argv[0];
if (argc < 2) { if (argc < 2) {
...@@ -214,19 +227,17 @@ main (int argc, char ** argv) ...@@ -214,19 +227,17 @@ main (int argc, char ** argv)
return (1); return (1);
} }
while (1) { if (!strncmp (argv[1], "-?", 2)) {
char * optstring = "f:khvo:";
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
static struct option long_options[] = { ot_print_options (long_options, optstring);
{"output", required_argument, 0, 'o'}, #else
{"format", required_argument, 0, 'f'}, ot_print_short_options (optstring);
{"keyframe", no_argument, 0, 'k'}, #endif
{"help", no_argument, 0, 'h'}, exit (0);
{"version", no_argument, 0, 'v'}, }
{0,0,0,0}
};
while (1) {
#ifdef HAVE_GETOPT_LONG
i = getopt_long(argc, argv, optstring, long_options, NULL); i = getopt_long(argc, argv, optstring, long_options, NULL);
#else #else
i = getopt (argc, argv, optstring); i = getopt (argc, argv, optstring);
......
...@@ -336,6 +336,18 @@ main (int argc, char * argv[]) ...@@ -336,6 +336,18 @@ main (int argc, char * argv[])
OSData * osdata; OSData * osdata;
int i; int i;
char * optstring = "hvVo:";
#ifdef HAVE_GETOPT_LONG
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{"verbose", no_argument, 0, 'V'},
{"output", required_argument, 0, 'o'},
{0,0,0,0}
};
#endif
ot_init (); ot_init ();
progname = argv[0]; progname = argv[0];
...@@ -345,20 +357,19 @@ main (int argc, char * argv[]) ...@@ -345,20 +357,19 @@ main (int argc, char * argv[])
return (1); return (1);
} }
if (!strncmp (argv[1], "-?", 2)) {
#ifdef HAVE_GETOPT_LONG
ot_print_options (long_options, optstring);
#else
ot_print_short_options (optstring);
#endif
exit (0);
}
osdata = osdata_new(); osdata = osdata_new();
while (1) { while (1) {
char * optstring = "hvVo:";
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{"verbose", no_argument, 0, 'V'},
{"output", required_argument, 0, 'o'},
{0,0,0,0}
};
i = getopt_long (argc, argv, optstring, long_options, NULL); i = getopt_long (argc, argv, optstring, long_options, NULL);
#else #else
i = getopt (argc, argv, optstring); i = getopt (argc, argv, optstring);
......
...@@ -419,6 +419,21 @@ main (int argc, char ** argv) ...@@ -419,6 +419,21 @@ main (int argc, char ** argv)
char * filename; char * filename;
int i = 1; int i = 1;
char * optstring = "M:psPhvE";
#ifdef HAVE_GETOPT_LONG
static struct option long_options[] = {
{"max-errors", required_argument, 0, 'M'},
{"prefix", no_argument, 0, 'p'},
{"suffix", no_argument, 0, 's'},
{"partial", no_argument, 0, 'P'},
{"help", no_argument, 0, 'h'},
{"help-errors", no_argument, 0, 'E'},
{"version", no_argument, 0, 'v'},
{0,0,0,0}
};
#endif
ot_init(); ot_init();
progname = argv[0]; progname = argv[0];
...@@ -428,21 +443,17 @@ main (int argc, char ** argv) ...@@ -428,21 +443,17 @@ main (int argc, char ** argv)
return (1); return (1);
} }
while (1) { if (!strncmp (argv[1], "-?", 2)) {
char * optstring = "M:psPhvE";
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
static struct option long_options[] = { ot_print_options (long_options, optstring);
{"max-errors", required_argument, 0, 'M'}, #else
{"prefix", no_argument, 0, 'p'}, ot_print_short_options (optstring);
{"suffix", no_argument, 0, 's'}, #endif
{"partial", no_argument, 0, 'P'}, exit (0);
{"help", no_argument, 0, 'h'}, }
{"help-errors", no_argument, 0, 'E'},
{"version", no_argument, 0, 'v'},
{0,0,0,0}
};
while (1) {
#ifdef HAVE_GETOPT_LONG
i = getopt_long(argc, argv, optstring, long_options, NULL); i = getopt_long(argc, argv, optstring, long_options, NULL);
#else #else
i = getopt (argc, argv, optstring); i = getopt (argc, argv, optstring);
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>