summaryrefslogtreecommitdiff
path: root/COMMIT-QUEUE.ini
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-05-17 16:22:25 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-05-24 15:09:12 -0700
commit72813bf7cedc63ff1cf43ed86f063cf37e850f7e (patch)
treebede444af2b7d5517e5cabcb2b05f0c7f2353243 /COMMIT-QUEUE.ini
parent78ec9d739a404a64b03d50d5b83c0520b790f7a6 (diff)
downloadchrome-ec-72813bf7cedc63ff1cf43ed86f063cf37e850f7e.tar.gz
gsctool: refactor command line arguments processing
There are a couple of issues with command line processing code: - command line options must be listed in two different places if we want to allow both short and long forms of the same argument - help text for commands is included in yet another place in the code Indeed, from the libc getopt_long() point of view the long options table and short options string are completely unrelated: the function scans the command line arguments vector for -x[x[y]] or --word command line options style and looks up either short_opts or long_opts depending on the encountered command line token's style. The standard way to cross reference long options table and the short options string is to put the short option character in the long option table's entries .val field. This is how it is done in gsctool. What this means is that as long as all short command options are referenced in the long_opts table, the short command option string could be generated based no the long_opts table. The help text and long_opts table would still remain separate and require manual syncing. To help with that problem this patch introduces a container structure, which includes both long option contents and the help text for each command line option. This allows to build the long_opts table and then the short_opts string on the fly, based on the contents of the single table, and also generated the --help output, ensuring consistency of all representations. BRANCH=none BUG=none TEST=as follows: - temporarily added debug code to print out the generated short option string, got the following: aBbcd:fF:hIikLMmn:O:oPpR:rS:stUuVvw which is extended to include previously omitted 'f': aBbcd:F:fhIikLMmn:O:oPpR:rS:stUuVvw - verified that 'gsctool -h' outputs before and after this patch are the same apart from including help text for -B - verified that it is still possible to update a Cr50 - verified --board_id/-i command with various optional parameter representations. Change-Id: Ie8d409c6c8866247323cee93ce5b9bfbe22046fa Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1617077 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
Diffstat (limited to 'COMMIT-QUEUE.ini')
0 files changed, 0 insertions, 0 deletions