Permalink
Browse files

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
  • Loading branch information...
conrad
conrad committed Aug 3, 2008
1 parent 269b018 commit aad1d701095d23a0df7237d37f01807b6334d4e4
@@ -251,6 +251,11 @@ main (int argc, char ** argv)
return (1);
}
+ if (!strncmp (argv[1], "-?", 2)) {
+ printf ("-h --help\n");
+ exit (0);
+ }
+
if (!strcmp (argv[1], "-h") || !strcmp (argv[1], "--help")) {
usage (progname);
return (0);
View
@@ -38,31 +38,42 @@ cmd_main (OCState * state, int argc, char * argv[])
int show_help = 0;
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];
if (argc < 2) {
usage (progname);
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));
state->end = -1.0;
state->do_skeleton = 1;
while (1) {
- 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}
- };
-
i = getopt_long(argc, argv, optstring, long_options, NULL);
#else
i = getopt (argc, argv, optstring);
View
@@ -386,10 +386,35 @@ main (int argc, char ** argv)
long n;
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 ();
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) {
usage (progname);
return (1);
@@ -398,21 +423,7 @@ main (int argc, char ** argv)
ocdata = ocdata_new ();
while (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}
- };
-
i = getopt_long(argc, argv, optstring, long_options, NULL);
#else
i = getopt (argc, argv, optstring);
View
@@ -59,13 +59,26 @@ usage () {
GETOPTEST=`getopt --version`
case $GETOPTEST in
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 ?
- 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
+# 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
usage
fi
View
@@ -505,6 +505,27 @@ main (int argc, char ** argv)
int filter_serialnos = 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 ();
progname = argv[0];
@@ -514,31 +535,21 @@ main (int argc, char ** argv)
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->read_packet = read_packet;
while (1) {
- 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}
- };
-
i = getopt_long(argc, argv, optstring, long_options, NULL);
#else
i = getopt (argc, argv, optstring);
View
@@ -516,29 +516,40 @@ main (int argc, char ** argv)
OGGZ * oggz;
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];
if (argc < 2) {
usage (progname);
return (1);
}
- while (1) {
- char * optstring = "hvlbgpka";
-
+ if (!strncmp (argv[1], "-?", 2)) {
#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'},
- {0,0,0,0}
- };
+ ot_print_options (long_options, optstring);
+#else
+ ot_print_short_options (optstring);
+#endif
+ exit (0);
+ }
+ while (1) {
+#ifdef HAVE_GETOPT_LONG
i = getopt_long (argc, argv, optstring, long_options, NULL);
#else
i = getopt (argc, argv, optstring);
@@ -78,7 +78,10 @@ main (int argc, char ** argv)
char * progname = argv[0];
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);
exit (0);
} else if (!strncmp (argv[1], "-h", 2) || !strncmp (argv[1], "--help", 6)) {
View
@@ -331,6 +331,18 @@ main (int argc, char * argv[])
OMData * omdata;
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 ();
progname = argv[0];
@@ -340,20 +352,19 @@ main (int argc, char * argv[])
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();
while (1) {
- 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}
- };
-
i = getopt_long (argc, argv, optstring, long_options, NULL);
#else
i = getopt (argc, argv, optstring);
View
@@ -306,6 +306,21 @@ main (int argc, char * argv[])
long l;
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();
progname = argv[0];
@@ -315,23 +330,19 @@ main (int argc, char * argv[])
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 ();
while (1) {
- 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}
- };
-
i = getopt_long (argc, argv, optstring, long_options, NULL);
#else
i = getopt (argc, argv, optstring);
Oops, something went wrong.

0 comments on commit aad1d70

Please sign in to comment.