[PATCH 1/9] improve the layout of the help output

Ray Strode halfline at gmail.com
Mon Feb 23 13:07:05 PST 2009


Hi,
On Mon, Feb 23, 2009 at 3:35 PM,  <william.jon.mccann at gmail.com> wrote:
> From: William Jon McCann <jmccann at redhat.com>
>
> Left align descriptions and group subcommands.
Ah, this looks a lot better.

> --- a/src/libply/ply-command-parser.c
> +++ b/src/libply/ply-command-parser.c
> @@ -139,26 +139,37 @@ append_usage_line_to_buffer (ply_command_parser_t *parser,
>
>   ply_buffer_append (buffer, "%s\n",
>                      parser->main_command->description);
> -  ply_buffer_append (buffer, "USAGE: %s", parser->main_command->name);
> +  ply_buffer_append (buffer, "USAGE: %s [OPTION...]", parser->main_command->name);
>
> -  option_node = ply_list_get_first_node (parser->main_command->options);
> -  while (option_node != NULL)
> -    {
> -      ply_command_option_t *option;
> +  if (ply_list_get_length (parser->available_subcommands) > 0)
> +    ply_buffer_append (buffer, " [subcommand [options]...]\n");
> +}
Why is OPTION uppercase but subcommand and options are lowercase?

[...]
> +  command_node = ply_list_get_first_node (parser->available_subcommands);
> +  while (command_node != NULL)
> +    {
> +      ply_command_t *command;
> +
> +      command = (ply_command_t *) ply_list_node_get_data (command_node);
> +
> +      if (ply_list_get_first_node (command->options) != NULL)
> +        {
> +          ply_buffer_append (buffer, "\nSubcommand Options (%s):\n", command->name);
> +
> +          append_command_options_to_buffer (parser, command, buffer);
> +        }
The "Subcommand Options (%s)" looks a little repetitive in the output.

Maybe it would be better if it were more sentence-y, like:

"Options for ask-for-password subcommand:"

I'm don't really care either way, but if you feel your proposed way is
better than the above, you should fix the inconsistency where
"Subcommand Options" is titlecase and "Available subcommands" isn't.

Feel free to push this one.

--Ray


More information about the plymouth mailing list