Patchwork [15/19] Expand query-argv to include help string

login
register
mail settings
Submitter Daniel P. Berrange
Date June 7, 2010, 2:42 p.m.
Message ID <1275921752-29420-16-git-send-email-berrange@redhat.com>
Download mbox | patch
Permalink /patch/54879/
State New
Headers show

Comments

Daniel P. Berrange - June 7, 2010, 2:42 p.m.
This expands the query-argv data format to include the help
string for each argument. This is not really very desirable
since the help strings are not in a predictable format for apps
to use. Ideally the full structured details about each argument
parameter would be included instead. This makes the data format
look like

    [
        {
            "name": "help",
            "help": "-h or -help     display this help and exit\n",
        },
        {
            "name": "M",
            "help": "-M machine      select emulated machine (-M ? for list)\n",
            "parameters": [
            ]
        },
    ]

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 vl.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

Patch

diff --git a/vl.c b/vl.c
index a76c673..35d2b51 100644
--- a/vl.c
+++ b/vl.c
@@ -2030,14 +2030,14 @@  void do_info_argv(Monitor *mon, QObject **data)
        const char *help;
     } options_help[] = {
 #define DEF(option, opt_arg, opt_enum, opt_help, arch_mask)     \
-        { option, opt_arg },
+        { option, opt_arg, opt_help },
 #define DEFHEADING(text)
 #define HAS_ARG 1
 #include "qemu-options.h"
 #undef DEF
 #undef DEFHEADING
 #undef HAS_ARG
-       { NULL, 0 },
+	{ NULL, 0, NULL },
     };
     int i;
 
@@ -2046,14 +2046,15 @@  void do_info_argv(Monitor *mon, QObject **data)
 
 	if (options_help[i].has_arg) {
 	    /* XXX actually fill in the parameter details */
-	    opt = qobject_from_jsonf("{ 'name': %s, 'parameters': [] }",
-				     options_help[i].name);
+	    opt = qobject_from_jsonf("{ 'name': %s, 'help': %s, 'parameters': [] }",
+				     options_help[i].name,
+				     options_help[i].help);
 	} else {
-	    opt = qobject_from_jsonf("{ 'name': %s }",
-				     options_help[i].name);
+	    opt = qobject_from_jsonf("{ 'name': %s, 'help': %s }",
+				     options_help[i].name,
+				     options_help[i].help);
 	}
 
-
 	qlist_append_obj(args, opt);
     }