On 01/05/2016 11:46 AM, [email protected] wrote:
> From: Dylan Baker <[email protected]>

Please use 'wflinfo', not 'wflinfo.c', as the commit's subject prefix.

> 
> This adds some code to print a JSON formatted version of data provided
> by wflinfo.
> 
> Signed-off-by: Dylan Baker <[email protected]>
> 
> v2: - Add -j short options (Frank)
>     - Make context flags always an array (Chad)
>     - Remove explicit returns from void functions (Chad)
>     - Fix spaces around "*" in variable definitions
>     - Nest waffle specific information in a waffle hash and OpenGL
>       specific information in an OpenGL hash
>     - use ARRAY_SIZE macro
>     - rebase on previous changes
> ---
>  src/utils/wflinfo.c | 178 
> +++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 176 insertions(+), 2 deletions(-)

Dylan, please review the JSON format I documented in my earlier message
titled "Approaches to JSON". If that format is acceptable to you, and to
Frank too, then please make this patch's JSON match the documented format.
That should require only a few touchups, as the format I documented closely
resembles your patch's existing format.

> diff --git a/src/utils/wflinfo.c b/src/utils/wflinfo.c
> index 8ee95c6..456f91b 100644
> --- a/src/utils/wflinfo.c
> +++ b/src/utils/wflinfo.c
> @@ -85,6 +85,9 @@ static const char *usage_message =
>      "    --debug-context\n"
>      "        Create a debug context.\n"
>      "\n"
> +    "    -j, --json\n"
> +    "        Print a JSON formatted summary.\n"
> +    "\n"
>      "    -h, --help\n"
>      "        Print wflinfo usage information.\n"
>      "\n"
> @@ -104,6 +107,7 @@ enum {
>      OPT_VERBOSE = 'v',
>      OPT_DEBUG_CONTEXT,
>      OPT_FORWARD_COMPATIBLE,
> +    OPT_JSON = 'j',
>      OPT_HELP = 'h',
>  };
>  
> @@ -115,6 +119,7 @@ static const struct option get_opts[] = {
>      { .name = "verbose",        .has_arg = no_argument,           .val = 
> OPT_VERBOSE },
>      { .name = "debug-context",  .has_arg = no_argument,           .val = 
> OPT_DEBUG_CONTEXT },
>      { .name = "forward-compatible", .has_arg = no_argument,       .val = 
> OPT_FORWARD_COMPATIBLE },
> +    { .name = "json",           .has_arg = no_argument,           .val = 
> OPT_JSON },
>      { .name = "help",           .has_arg = no_argument,           .val = 
> OPT_HELP },
>      { 0 },
>  };

[snip]

I like Frank's idea of adding an '-f|--format' option, like this:

    -f <format>, --format=<format>
        Print output in the given format. Available formats are
        'flat' and 'json'. Defaults to 'flat'.

That would allow us to add additional formats in the future without
reserving a new option letter for each format. Is that change ok with you?
_______________________________________________
waffle mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/waffle

Reply via email to