summaryrefslogtreecommitdiff
path: root/gen-manpage-opts.c
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2008-02-13 10:26:52 -0800
committerAaron Plattner <aplattner@nvidia.com>2008-02-13 10:26:52 -0800
commitc1cb49fc2abcb44580f7544e2ac8f987da5205cc (patch)
treec4f28e1ec22fab18a7f95fa2768badd263d0fd6b /gen-manpage-opts.c
Diffstat (limited to 'gen-manpage-opts.c')
-rw-r--r--gen-manpage-opts.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/gen-manpage-opts.c b/gen-manpage-opts.c
new file mode 100644
index 0000000..c656003
--- /dev/null
+++ b/gen-manpage-opts.c
@@ -0,0 +1,70 @@
+/*
+ * Prints the option help in a form that is suitable to include in the manpage.
+ */
+#include <stdio.h>
+#include <ctype.h>
+
+#include "XF86Config-parser/xf86Parser.h"
+#include "nvidia-xconfig.h"
+#include "nvgetopt.h"
+#include "option_table.h"
+
+static void print_option(const NVGetoptOption *o)
+{
+ printf(".TP\n.BI ");
+ /* Print the name of the option */
+ /* XXX We should backslashify the '-' characters in o->name. */
+ if (o->flags & NVGETOPT_IS_BOOLEAN) {
+ /* "\-\-name, \-\-no\-name */
+ printf("\"\\-\\-%s, \\-\\-no\\-%s", o->name, o->name);
+ } else if (isalpha(o->val)) {
+ /* "\-c, \-\-name */
+ printf("\"\\-%c, \\-\\-%s", o->val, o->name);
+ } else {
+ /* "\-\-name */
+ printf("\"\\-\\-%s", o->name);
+ }
+
+ if (o->flags & NVGETOPT_HAS_ARGUMENT) {
+ printf("=\" \"%s", o->name);
+ }
+
+ printf("\"\n");
+
+ /* Print the option description */
+ /* XXX Each sentence should be on its own line! */
+ /* XXX We need to backslashify the '-' characters here. */
+ printf("%s\n", o->description);
+}
+
+int main(int argc, char* argv[])
+{
+ int i;
+ const NVGetoptOption *o;
+
+ /* Print the "simple" options, i.e. the ones you get by running
+ * nvidia-xconfig --help.
+ */
+ printf(".SH OPTIONS\n");
+ for (i = 0; __options[i].name; i++) {
+ o = &__options[i];
+
+ if (!(o->flags & OPTION_HELP_ALWAYS))
+ continue;
+
+ print_option(o);
+ }
+
+ /* Print the advanced options. */
+ printf(".SH \"ADVANCED OPTIONS\"\n");
+ for (i = 0; __options[i].name; i++) {
+ o = &__options[i];
+
+ if (o->flags & OPTION_HELP_ALWAYS)
+ continue;
+
+ print_option(o);
+ }
+
+ return 0;
+}