BACKPORT: cli_classic: Tidy up some repeated handling patterns into funcs

Introduce cli_classic_single_operation() to consolidate the repeating
pattern of multiple CLI operations at once. Also modify
cli_classic_abort_usage() to take an optional error abort string and
print it to stderr, this allows for trimming a few more lines off the
cli implementation.

V.2: A few fixes upon review:
  - Trim off some unnecessary braces for single line branches.
  - Pass 'operation_specified' by reference.
  - Rename a function.
V.3: Fix print order of cli_classic_abort_usage().

Original-Change-Id: I54598efdaee2b95cb278b0f2aac05f48bbd95bef
Original-Signed-off-by: Edward O'Callaghan <quasisec@chromium.org>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/35611
Original-Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Original-Reviewed-by: Nico Huber <nico.h@gmx.de>
(cherry picked from commit 8b60fc7a5bac409f8a4e0648f1fba51aa3497afb)

This brings over cli_classic_single_operation() and the changes
to cli_classic_abort_usage() from the upstream patch. However
cli_classic.c has significantly diverged from upstream, so not
all changes to their call sites correspond to the original patch.

BUG=b:157519185
BRANCH=none
TEST=builds

Tested-by: Nikolai Artemiev <nartemiev@chromium.org>
Signed-off-by: Nikolai Artemiev <nartemiev@chromium.org>
Change-Id: I652c9fc2690c3eed5472c22f24c6927e57829f87
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/+/2217164
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Tested-by: Edward O'Callaghan <quasisec@chromium.org>
Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
1 file changed