From: Programmingkid <programmingkidx@gmail.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Max Reitz <mreitz@redhat.com>, Qemu-block <qemu-block@nongnu.org>,
QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] qemu-img.c: add help for each command
Date: Mon, 10 Sep 2018 10:19:46 -0400 [thread overview]
Message-ID: <0B577F71-321C-4A6E-A75B-C7EEB8472C6E@gmail.com> (raw)
In-Reply-To: <20180910081649.GA4901@dhcp-200-186.str.redhat.com>
> On Sep 10, 2018, at 4:16 AM, Kevin Wolf <kwolf@redhat.com> wrote:
>
> Am 08.09.2018 um 05:16 hat Programmingkid geschrieben:
>>
>>> On Sep 7, 2018, at 11:13 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
>>>
>>> On 8 September 2018 at 04:01, John Arbuckle <programmingkidx@gmail.com> wrote:
>>>
>>>> + /* print the help for this command */
>>>> + if (strcmp("--help", argv[optind + 1]) == 0) {
>>>> + if (strcmp("amend", cmdname) == 0) {
>>>> + help_amend();
>>>> + } else if (strcmp("bench", cmdname) == 0) {
>>>> + help_bench();
>>>> + } else if (strcmp("check", cmdname) == 0) {
>>>> + help_check();
>>>> + } else if (strcmp("commit", cmdname) == 0) {
>>>> + help_commit();
>>>> + } else if (strcmp("compare", cmdname) == 0) {
>>>> + help_compare();
>>>> + } else if (strcmp("convert", cmdname) == 0) {
>>>> + help_convert();
>>>> + } else if (strcmp("create", cmdname) == 0) {
>>>> + help_create();
>>>> + } else if (strcmp("dd", cmdname) == 0) {
>>>> + help_dd();
>>>> + } else if (strcmp("info", cmdname) == 0) {
>>>> + help_info();
>>>> + } else if (strcmp("map", cmdname) == 0) {
>>>> + help_map();
>>>> + } else if (strcmp("measure", cmdname) == 0) {
>>>> + help_measure();
>>>> + } else if (strcmp("snapshot", cmdname) == 0) {
>>>> + help_snapshot();
>>>> + } else if (strcmp("rebase", cmdname) == 0) {
>>>> + help_rebase();
>>>> + } else if (strcmp("resize", cmdname) == 0) {
>>>> + help_resize();
>>>
>>> Any time you find yourself writing very repetitive code like
>>> this, it's a good idea to ask yourself "is there a way to make
>>> this data-driven?".
>>>
>>> thanks
>>> -- PMM
>>
>> Did you want me to loop thru an array of strings instead?
>
> There is already an array of all subcommands, img_cmds. You should
> probably add another field there for the help text.
Even though I would prefer to leave the img_cmds array alone, I do
see the advantages of your suggestion. All the code that checks which
command is being used could go. I will ad a help_text field to this
array.
> Also, your line wrapping (even mid-word!) is awful. I'm not sure we
> really have to fill 80 characters in the output and can't simply keep
> the lines a bit shorter so that 80 characters in the source are enough.
Yeah it does look very unreadable like that.
> But if we do want to use the full 80 characters in the output, I'd
> rather break the limit from the coding style and use longer lines in the
> source coe than doing what you did.
Using lines longer than 80 would make the patch a lot easier to read. I will do this.
Thank you.
prev parent reply other threads:[~2018-09-10 14:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-08 3:01 [Qemu-devel] [PATCH] qemu-img.c: add help for each command John Arbuckle
2018-09-08 3:13 ` Peter Maydell
2018-09-08 3:16 ` Programmingkid
2018-09-10 8:16 ` Kevin Wolf
2018-09-10 14:19 ` Programmingkid [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0B577F71-321C-4A6E-A75B-C7EEB8472C6E@gmail.com \
--to=programmingkidx@gmail.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).