> On Sep 7, 2018, at 11:13 PM, Peter Maydell <peter.mayd...@linaro.org> wrote:
> 
> On 8 September 2018 at 04:01, John Arbuckle <programmingk...@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?

Reply via email to