[Libguestfs] [PATCH 0/2] RFC: add output selection for --machine-readable

Pino Toscano
Tue, 21 Aug 2018 15:44:28 -0000

Hi,

this is a first approach (hence RFC, since it misses tests &
documentation) in selecting the output for --machine-readable.

The possible choices are:
* --machine-readable: to stdout, like before
* --machine-readable=file:name-of-file: to the specified file
* --machine-readable=stream:stdout: explicitly to stdout
* --machine-readable=stream:stderr: explicitly to stderr

This makes it possible to add additional output for machine-readable in
the tools, with the possibility for users to get it separately from the
rest of the output/errors of the tool used.
For example, the proposed --print-estimate for virt-v2v [1] could print
human output (just like the --print-source), while printing e.g. JSON to
the machine-readable stream.

[1] https://www.redhat.com/archives/libguestfs/2018-August/msg00158.html

Thanks,


Pino Toscano (2):
  common/mltools: getopt: add Getopt.OptString
  OCaml tools: add output selection for --machine-readable

 builder/cmdline.ml             | 12 ++++----
 builder/repository_main.ml     |  2 +-
 common/mltools/getopt-c.c      | 20 ++++++++++++-
 common/mltools/getopt.ml       |  5 +++-
 common/mltools/getopt.mli      |  4 +++
 common/mltools/getopt_tests.ml | 18 +++++++++++-
 common/mltools/test-getopt.sh  | 11 +++++++
 common/mltools/tools_utils.ml  | 52 +++++++++++++++++++++++++++++++++-
 common/mltools/tools_utils.mli |  6 ++++
 dib/cmdline.ml                 |  4 +--
 get-kernel/get_kernel.ml       |  2 +-
 resize/resize.ml               | 22 +++++++-------
 sparsify/cmdline.ml            | 16 +++++------
 v2v/cmdline.ml                 | 28 +++++++++---------
 14 files changed, 155 insertions(+), 47 deletions(-)

--
2.17.1