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

William Jon McCann william.jon.mccann at gmail.com
Mon Feb 23 13:34:05 PST 2009


Hey,

On Mon, Feb 23, 2009 at 4:07 PM, Ray Strode <halfline at gmail.com> wrote:
> 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?

The uppercase is because I was trying to be consistent with GOption.
The later is not because I erred on the side of fewer changes.
Probably makes sense to capitalize both and possibly even SUBCOMMAND -
or maybe even replace subcommand with COMMAND (a la git).

> [...]
>> +  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.

Sure that's fine too.  Maybe even "Options for %s command:" ?

Thanks,
Jon


More information about the plymouth mailing list