Hi, this adds the possibility to select the output for --machine-readable in OCaml tools.
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 Changes from v1: - adjusted the formatting for help text in patch #1 - moved all the machine_readable machinery in Tools_utils - expose all in a single machine_readable () function - add a test - add the documentation bits Thanks, Pino Toscano (2): common/mltools: getopt: add Getopt.OptString OCaml tools: add output selection for --machine-readable .gitignore | 1 + builder/cmdline.ml | 16 +++--- builder/repository_main.ml | 6 ++- builder/virt-builder-repository.pod | 5 ++ builder/virt-builder.pod | 5 ++ common/mlstdutils/std_utils.ml | 4 -- common/mlstdutils/std_utils.mli | 7 +-- common/mltools/Makefile.am | 35 ++++++++++++- common/mltools/getopt-c.c | 20 ++++++- common/mltools/getopt.ml | 26 +++++++-- common/mltools/getopt.mli | 4 ++ common/mltools/getopt_tests.ml | 18 ++++++- common/mltools/machine_readable_tests.ml | 41 +++++++++++++++ common/mltools/test-getopt.sh | 11 ++++ common/mltools/test-machine-readable.sh | 67 ++++++++++++++++++++++++ common/mltools/tools_utils.ml | 53 ++++++++++++++++++- common/mltools/tools_utils.mli | 10 ++++ dib/cmdline.ml | 8 +-- dib/virt-dib.pod | 5 ++ get-kernel/get_kernel.ml | 6 ++- get-kernel/virt-get-kernel.pod | 5 ++ lib/guestfs.pod | 30 +++++++++++ resize/resize.ml | 36 ++++++++----- resize/virt-resize.pod | 5 ++ sparsify/cmdline.ml | 20 +++---- sparsify/copying.ml | 5 +- sparsify/in_place.ml | 5 +- sparsify/virt-sparsify.pod | 5 ++ v2v/cmdline.ml | 32 +++++------ v2v/virt-v2v.pod | 5 ++ 30 files changed, 424 insertions(+), 72 deletions(-) create mode 100644 common/mltools/machine_readable_tests.ml create mode 100755 common/mltools/test-machine-readable.sh -- 2.17.1 _______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
