]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Improve help/man page of para_write.
authorAndre Noll <maan@systemlinux.org>
Sat, 6 Dec 2008 13:37:03 +0000 (14:37 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 6 Dec 2008 13:37:03 +0000 (14:37 +0100)
Makefile.in
alsa_write.c
alsa_write.ggo
configure.ac
file_write.c
file_write.ggo
write.c
write.ggo
write.h
write_common.c

index 9e78b67dabb8e924f003a21ef0c87f2078568410..1563739bfa50cd9c47cda249057a986e83b53668 100644 (file)
@@ -117,6 +117,7 @@ grab_client.cmdline.h grab_client.cmdline.c: grab_client.ggo
                fsck.ggo) O="--unamed-opts=table";; \
                afh.ggo) O="--unamed-opts=audio_file";; \
                filter.ggo) O="--no-handle-help";; \
                fsck.ggo) O="--unamed-opts=table";; \
                afh.ggo) O="--unamed-opts=audio_file";; \
                filter.ggo) O="--no-handle-help";; \
+               write.ggo) O="--no-handle-help";; \
        esac; \
        if test $< != fsck.ggo; then O="$$O --conf-parser "; fi; \
        gengetopt $$O \
        esac; \
        if test $< != fsck.ggo; then O="$$O --conf-parser "; fi; \
        gengetopt $$O \
@@ -148,6 +149,10 @@ man/man1/para_filter.1: para_filter
        mkdir -p man/man1
        help2man -h --detailed-help -N ./$< > $@
 
        mkdir -p man/man1
        help2man -h --detailed-help -N ./$< > $@
 
+man/man1/para_write.1: para_write
+       mkdir -p man/man1
+       help2man -h --detailed-help -N ./$< > $@
+
 man/man1/%.1: %
        mkdir -p man/man1
        help2man -N ./$< > $@
 man/man1/%.1: %
        mkdir -p man/man1
        help2man -N ./$< > $@
index 89d1995caccc24ecc8f988dff8d5862c56ad0b69..9f60d6d88aacbd21715f529d61c5bd3e23dd6cd4 100644 (file)
@@ -21,6 +21,7 @@
 #include "string.h"
 #include "list.h"
 #include "sched.h"
 #include "string.h"
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "write.h"
 #include "alsa_write.cmdline.h"
 #include "error.h"
 #include "write.h"
 #include "alsa_write.cmdline.h"
 #include "error.h"
@@ -236,10 +237,19 @@ err_out:
  */
 void alsa_write_init(struct writer *w)
 {
  */
 void alsa_write_init(struct writer *w)
 {
+       struct alsa_write_args_info dummy;
+
+       alsa_cmdline_parser_init(&dummy);
        w->open = alsa_open;
        w->close = alsa_close;
        w->pre_select = alsa_write_pre_select;
        w->post_select = alsa_write_post_select;
        w->parse_config = alsa_parse_config;
        w->shutdown = NULL; /* nothing to do */
        w->open = alsa_open;
        w->close = alsa_close;
        w->pre_select = alsa_write_pre_select;
        w->post_select = alsa_write_post_select;
        w->parse_config = alsa_parse_config;
        w->shutdown = NULL; /* nothing to do */
+       w->help = (struct ggo_help) {
+               .purpose = alsa_write_args_info_purpose,
+               .usage = alsa_write_args_info_usage,
+               .short_help = alsa_write_args_info_help,
+               .detailed_help = alsa_write_args_info_detailed_help
+       };
 }
 }
index 371ec89f259ebae40581c6031f6e3aba51dd23d3..84f49d58916bcce0ba51e1ab65347f25eb7c58a5 100644 (file)
@@ -1,28 +1,34 @@
-section "alsa options"
-######################
-
 option "device" d
 #~~~~~~~~~~~~~~~~
 "set PCM device"
 option "device" d
 #~~~~~~~~~~~~~~~~
 "set PCM device"
-       string typestr="device"
-       default="default"
-       optional
+string typestr="device"
+default="default"
+optional
+details="
+       On systems with dmix, a better choice than the default
+       value might be to use \"plug:swmix\".
+"
 
 option "channels" c
 #~~~~~~~~~~~~~~~~~~
 
 option "channels" c
 #~~~~~~~~~~~~~~~~~~
-"number of channels (only necessary for raw
-audio)"
-
-       int typestr="num"
-       default="2"
-       optional
+"specify number of channels"
+int typestr="num"
+default="2"
+optional
+details="
+       This option is only necessary for playing raw audio with
+       para_write.  In all other cases (plaing wav files with
+       para_write or using this writer with para_audiod), the number
+       of channels will be obtained from other resources.
+"
 
 option "samplerate" s
 #~~~~~~~~~~~~~~~~~~~~~
 
 option "samplerate" s
 #~~~~~~~~~~~~~~~~~~~~~
-
-"force given sample rate (only necessary for
-raw audio)"
-
-       int typestr="num"
-       default="44100"
-       optional
+"force given sample rate"
+int typestr="num"
+default="44100"
+optional
+details="
+       Again, it is only necessary to specify this when playing raw
+       audio with para_write.
+"
index 2429bfbdf2512ca482bb81ba3641c336e6d09010..04a4e934c6ab7b2d90d9d9825ac30e4f13c431aa 100644 (file)
@@ -127,7 +127,7 @@ server_ldflags=""
 server_audio_formats=" mp3"
 
 write_cmdline_objs="write.cmdline file_write.cmdline"
 server_audio_formats=" mp3"
 
 write_cmdline_objs="write.cmdline file_write.cmdline"
-write_errlist_objs="write write_common file_write time fd string sched stdin"
+write_errlist_objs="write write_common file_write time fd string sched stdin ggo"
 write_ldflags=""
 writers=" file"
 default_writer="FILE_WRITE"
 write_ldflags=""
 writers=" file"
 default_writer="FILE_WRITE"
index 839515f88ada154bcabc9d89b4a0f274d5911a94..be1e7713c0d818498a1cb860351c56c285e8dfff 100644 (file)
@@ -12,6 +12,7 @@
 #include "para.h"
 #include "list.h"
 #include "sched.h"
 #include "para.h"
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "write.h"
 #include "string.h"
 #include "fd.h"
 #include "write.h"
 #include "string.h"
 #include "fd.h"
@@ -109,10 +110,19 @@ __malloc static void *file_write_parse_config(const char *options)
 /** the init function of the file writer */
 void file_write_init(struct writer *w)
 {
 /** the init function of the file writer */
 void file_write_init(struct writer *w)
 {
+       struct file_write_args_info dummy;
+
+       file_cmdline_parser_init(&dummy);
        w->open = file_write_open;
        w->pre_select = file_write_pre_select;
        w->post_select = file_write_post_select;
        w->parse_config = file_write_parse_config;
        w->close = file_write_close;
        w->shutdown = NULL; /* nothing to do */
        w->open = file_write_open;
        w->pre_select = file_write_pre_select;
        w->post_select = file_write_post_select;
        w->parse_config = file_write_parse_config;
        w->close = file_write_close;
        w->shutdown = NULL; /* nothing to do */
+       w->help = (struct ggo_help) {
+               .purpose = file_write_args_info_purpose,
+               .usage = file_write_args_info_usage,
+               .short_help = file_write_args_info_help,
+               .detailed_help = file_write_args_info_detailed_help
+       };
 }
 }
index a172f75779aa201bf6b82f9808443b9c41275b1e..56c44f7a7a6096b0e7e338f9571168bb5f1c56d4 100644 (file)
@@ -1,11 +1,9 @@
-section "file writer options"
-
 option "filename" f
 #~~~~~~~~~~~~~~~~~~
 option "filename" f
 #~~~~~~~~~~~~~~~~~~
-
-"select output file name. Defaults to a
-random filename in ~/.paraslash."
-
-       string typestr="filename"
-       optional
+"specify output file name"
+string typestr="filename"
+optional
+details="
+       Defaults to a random filename in ~/.paraslash.
+"
 
 
diff --git a/write.c b/write.c
index 998a6d2cccde01cf45bcb6e5dea9d5e11c3f7da0..6e78e773c558f3d1c6d5fd8a15d0532645cec570 100644 (file)
--- a/write.c
+++ b/write.c
@@ -14,6 +14,7 @@
 #include "write.cmdline.h"
 #include "list.h"
 #include "sched.h"
 #include "write.cmdline.h"
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "stdin.h"
 #include "write.h"
 #include "write_common.h"
 #include "stdin.h"
 #include "write.h"
 #include "write_common.h"
@@ -129,20 +130,6 @@ static struct writer_node_group *check_args(void)
        struct writer_node_group *g = NULL;
        struct initial_delay_task *idt = &the_initial_delay_task;
 
        struct writer_node_group *g = NULL;
        struct initial_delay_task *idt = &the_initial_delay_task;
 
-       if (conf.list_writers_given) {
-               char *msg = NULL;
-               FOR_EACH_WRITER(i) {
-                       char *tmp = make_message("%s%s%s",
-                               i? msg : "",
-                               i? " " : "",
-                               writer_names[i]);
-                       free(msg);
-                       msg = tmp;
-               }
-               fprintf(stderr, "%s\n", msg);
-               free(msg);
-               exit(EXIT_SUCCESS);
-       }
        if (conf.start_time_given) {
                long unsigned sec, usec;
                if (sscanf(conf.start_time_arg, "%lu:%lu",
        if (conf.start_time_given) {
                long unsigned sec, usec;
                if (sscanf(conf.start_time_arg, "%lu:%lu",
@@ -174,6 +161,33 @@ out:
        return NULL;
 }
 
        return NULL;
 }
 
+__noreturn static void print_help_and_die(void)
+{
+       int i, d = conf.detailed_help_given;
+       const char **p = d? write_args_info_detailed_help
+               : write_args_info_help;
+
+       printf_or_die("%s\n\n", WRITE_CMDLINE_PARSER_PACKAGE "-"
+               WRITE_CMDLINE_PARSER_VERSION);
+       printf_or_die("%s\n\n", write_args_info_usage);
+       for (; *p; p++)
+               printf_or_die("%s\n", *p);
+
+       printf_or_die("\nAvailable writers: \n\t");
+       FOR_EACH_WRITER(i)
+               printf_or_die("%s%s", i? " " : "", writer_names[i]);
+       printf_or_die("\n\n");
+       FOR_EACH_WRITER(i) {
+               struct writer *w = writers + i;
+
+               if (!w->help.short_help)
+                       continue;
+               printf_or_die("Options for %s:\n", writer_names[i]);
+               ggo_print_help(&w->help, d);
+       }
+       exit(0);
+}
+
 /**
  * Para_write's main function.
  *
 /**
  * Para_write's main function.
  *
@@ -192,9 +206,11 @@ int main(int argc, char *argv[])
        struct check_wav_task *cwt = &the_check_wav_task;
        struct initial_delay_task *idt = &the_initial_delay_task;
 
        struct check_wav_task *cwt = &the_check_wav_task;
        struct initial_delay_task *idt = &the_initial_delay_task;
 
+       init_supported_writers();
        write_cmdline_parser(argc, argv, &conf);
        HANDLE_VERSION_FLAG("write", conf);
        write_cmdline_parser(argc, argv, &conf);
        HANDLE_VERSION_FLAG("write", conf);
-       init_supported_writers();
+       if (conf.help_given || conf.detailed_help_given)
+               print_help_and_die();
 
        wng = check_args();
        if (!wng)
 
        wng = check_args();
        if (!wng)
index 1ea8abf29265d9bc6c569f7fbeda5734cd70e972..8f557bb9de6ae1284a2e7e284e618cf75d4995bf 100644 (file)
--- a/write.ggo
+++ b/write.ggo
@@ -1,45 +1,35 @@
-section "general options"
-#########################
-
-option "list_writers" L
-#~~~~~~~~~~~~~~~~~~~~~~
-"print available writers and exit"
-
-       flag off
-
 option "loglevel" l
 #~~~~~~~~~~~~~~~~~~
 "set loglevel (0-6)"
 option "loglevel" l
 #~~~~~~~~~~~~~~~~~~
 "set loglevel (0-6)"
-
-       int typestr="level"
-       default="4"
-       optional
+int typestr="level"
+default="4"
+optional
 
 option "bufsize" b
 #~~~~~~~~~~~~~~~~~
 "input buffer size"
 
 option "bufsize" b
 #~~~~~~~~~~~~~~~~~
 "input buffer size"
-
-       int typestr="kilobytes"
-       default="64"
-       optional
+int typestr="kilobytes"
+default="64"
+optional
 
 option "writer" w
 #~~~~~~~~~~~~~~~~
 
 option "writer" w
 #~~~~~~~~~~~~~~~~
-
-"select stream writer
-may be give multiple times. The same writer
-may be specified more than once"
-
-       string typestr="name"
-       default="alsa (file if alsa is unsupported)"
-       optional
-       multiple
+"select stream writer"
+string typestr="name"
+default="alsa (file if alsa is unsupported)"
+optional
+multiple
+details="
+       May be give multiple times. The same writer may be specified
+       more than once.
+"
 
 option "start_time" t
 #~~~~~~~~~~~~~~~~~~~~
 
 option "start_time" t
 #~~~~~~~~~~~~~~~~~~~~
-"start playback at given time which must be
-in a:b format where a denotes seconds and b
-denotes microseconds since the epoch"
-
-       string typestr="timeval"
-       optional
+"defer playback"
+string typestr="timeval"
+optional
+details="
+       Start playback at given time which must be in a:b format where
+       a denotes seconds and b denotes microseconds since the epoch.
+"
diff --git a/write.h b/write.h
index 9723977ae4357506ac1c6b64284695577d1e5683..7df62f9f08e68090afe45cb09ec43dde024b7fab 100644 (file)
--- a/write.h
+++ b/write.h
@@ -84,6 +84,7 @@ struct writer {
         * This is a optional function pointer used for cleaning up.
         */
        void (*shutdown)(struct writer_node *);
         * This is a optional function pointer used for cleaning up.
         */
        void (*shutdown)(struct writer_node *);
+       struct ggo_help help;
 };
 
 /**
 };
 
 /**
index 3bf5d1199f560e9ce93b7d97a06e278ce495591f..d66b20ca112dd7cb1135d9211ff880cd2a2fc39c 100644 (file)
@@ -10,6 +10,7 @@
 #include "string.h"
 #include "list.h"
 #include "sched.h"
 #include "string.h"
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "write.h"
 #include "error.h"
 
 #include "write.h"
 #include "error.h"