Generate the usage message by walking the list of available programmers. This makes sure compiled out programmers are not listed.
Tested, usage output is identical to the hardcoded variant.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-programmer_usagemessage/flashrom.c =================================================================== --- flashrom-programmer_usagemessage/flashrom.c (Revision 680) +++ flashrom-programmer_usagemessage/flashrom.c (Arbeitskopie) @@ -486,6 +486,11 @@
void usage(const char *name) { + const char *pname; + int pnamelen; + int remaining = 0; + enum programmer p; + printf("usage: %s [-VfLzhR] [-E|-r file|-w file|-v file] [-c chipname]\n" " [-m [vendor:]part] [-l file] [-i image] [-p programmer]\n\n", name);
@@ -508,9 +513,33 @@ " -i | --image <name>: only flash image name from flash layout\n" " -L | --list-supported: print supported devices\n" " -z | --list-supported-wiki: print supported devices in wiki syntax\n" - " -p | --programmer <name>: specify the programmer device\n" - " (internal, dummy, nic3com, satasii,\n" - " it87spi, ft2232spi, serprog)\n" + " -p | --programmer <name>: specify the programmer device"); + + for (p = 0; p < PROGRAMMER_INVALID; p++) { + pname = programmer_table[p].name; + pnamelen = strlen(pname); + if (remaining - pnamelen - 2 < 0) { + printf("\n "); + remaining = 43; + } else { + printf(" "); + remaining--; + } + if (p == 0) { + printf("("); + remaining--; + } + printf("%s", pname); + remaining -= pnamelen; + if (p < PROGRAMMER_INVALID - 1) { + printf(","); + remaining--; + } else { + printf(")\n"); + } + } + + printf( " -h | --help: print this help text\n" " -R | --version: print the version (release)\n" "\nYou can specify one of -E, -r, -w, -v or no operation. If no operation is\n"
On 12.08.2009 17:12, Carl-Daniel Hailfinger wrote:
Generate the usage message by walking the list of available programmers. This makes sure compiled out programmers are not listed.
Tested, usage output is identical to the hardcoded variant.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Ping. This is 0.9.1 material.
Regards, Carl-Daniel
On 8/13/09 12:49 PM, Carl-Daniel Hailfinger wrote:
On 12.08.2009 17:12, Carl-Daniel Hailfinger wrote:
Generate the usage message by walking the list of available programmers. This makes sure compiled out programmers are not listed.
Tested, usage output is identical to the hardcoded variant.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Ping. This is 0.9.1 material.
Acked-by: Stefan Reinauer stepan@coresystems.de
On 13.08.2009 13:03, Stefan Reinauer wrote:
On 8/13/09 12:49 PM, Carl-Daniel Hailfinger wrote:
On 12.08.2009 17:12, Carl-Daniel Hailfinger wrote:
Generate the usage message by walking the list of available programmers. This makes sure compiled out programmers are not listed.
Tested, usage output is identical to the hardcoded variant.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Ping. This is 0.9.1 material.
Acked-by: Stefan Reinauer stepan@coresystems.de
Thanks, r684.
Regards, Carl-Daniel