Richard W.M. Jones
2017-Mar-10 14:04 UTC
[Libguestfs] [PATCH] v2v: Refactor some command line error messages.
This change (mostly) has no effect, except I changed the content of two error messages to make them consistent with the others. --- v2v/cmdline.ml | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml index a72aa49..c294e57 100644 --- a/v2v/cmdline.ml +++ b/v2v/cmdline.ml @@ -334,6 +334,11 @@ read the man page virt-v2v(1). error (f_"expecting an OVA file name on the command line") in Input_ova.input_ova filename in + (* Common error message. *) + let error_option_cannot_be_used_in_output_mode mode opt + error (f_"-o %s: %s option cannot be used in this output mode") mode opt + in + (* Parse the output mode. *) if output_mode <> `Not_set && in_place then error (f_"-o and --in-place cannot be used at the same time"); @@ -341,13 +346,13 @@ read the man page virt-v2v(1). match output_mode with | `Glance -> if output_conn <> None then - error (f_"-o glance: -oc option cannot be used in this output mode"); + error_option_cannot_be_used_in_output_mode "glance" "-oc"; if output_storage <> None then - error (f_"-o glance: -os option cannot be used in this output mode"); + error_option_cannot_be_used_in_output_mode "glance" "-os"; if qemu_boot then - error (f_"-o glance: --qemu-boot option cannot be used in this output mode"); + error_option_cannot_be_used_in_output_mode "glance" "--qemu-boot"; if not do_copy then - error (f_"--no-copy and '-o glance' cannot be used at the same time"); + error_option_cannot_be_used_in_output_mode "glance" "--no-copy"; Output_glance.output_glance (), output_format, output_alloc @@ -356,9 +361,9 @@ read the man page virt-v2v(1). let output_storage match output_storage with None -> "default" | Some os -> os in if qemu_boot then - error (f_"-o libvirt: --qemu-boot option cannot be used in this output mode"); + error_option_cannot_be_used_in_output_mode "libvirt" "--qemu-boot"; if not do_copy then - error (f_"--no-copy and '-o libvirt' cannot be used at the same time"); + error_option_cannot_be_used_in_output_mode "libvirt" "--no-copy"; Output_libvirt.output_libvirt output_conn output_storage, output_format, output_alloc @@ -371,21 +376,21 @@ read the man page virt-v2v(1). error (f_"-os %s: output directory does not exist or is not a directory") d | Some d -> d in if qemu_boot then - error (f_"-o local: --qemu-boot option cannot be used in this output mode"); + error_option_cannot_be_used_in_output_mode "local" "--qemu-boot"; Output_local.output_local os, output_format, output_alloc | `Null -> if output_alloc <> Sparse then - error (f_"-o null: -oa option cannot be used in this output mode"); + error_option_cannot_be_used_in_output_mode "null" "-oa"; if output_conn <> None then - error (f_"-o null: -oc option cannot be used in this output mode"); + error_option_cannot_be_used_in_output_mode "null" "-oc"; if output_format <> None then - error (f_"-o null: -of option cannot be used in this output mode"); + error_option_cannot_be_used_in_output_mode "null" "-of"; if output_storage <> None then - error (f_"-o null: -os option cannot be used in this output mode"); + error_option_cannot_be_used_in_output_mode "null" "-os"; if qemu_boot then - error (f_"-o null: --qemu-boot option cannot be used in this output mode"); + error_option_cannot_be_used_in_output_mode "null" "--qemu-boot"; Output_null.output_null (), (* Force output format to raw sparse in -o null mode. *) Some "raw", Sparse @@ -408,7 +413,7 @@ read the man page virt-v2v(1). error (f_"-o rhv: output storage was not specified, use '-os'"); | Some d -> d in if qemu_boot then - error (f_"-o rhv: --qemu-boot option cannot be used in this output mode"); + error_option_cannot_be_used_in_output_mode "rhv" "--qemu-boot"; Output_rhv.output_rhv os output_alloc, output_format, output_alloc @@ -419,7 +424,7 @@ read the man page virt-v2v(1). error (f_"-o vdsm: output storage was not specified, use '-os'"); | Some d -> d in if qemu_boot then - error (f_"-o vdsm: --qemu-boot option cannot be used in this output mode"); + error_option_cannot_be_used_in_output_mode "vdsm" "--qemu-boot"; let vdsm_vm_uuid match vdsm_vm_uuid with | None -> -- 2.9.3
Pino Toscano
2017-Mar-10 14:40 UTC
Re: [Libguestfs] [PATCH] v2v: Refactor some command line error messages.
On Friday, 10 March 2017 15:04:26 CET Richard W.M. Jones wrote:> This change (mostly) has no effect, except I changed the content of > two error messages to make them consistent with the others. > ---LGTM. Thanks, -- Pino Toscano
Possibly Parallel Threads
- [PATCH] v2v: -o null: Force output format to be raw sparse.
- [PATCH v2 3/3] v2v: Add -o rhv-upload output mode.
- [PATCH 5/5] v2v: Add -o rhv-upload output mode.
- Re: [PATCH 5/5] v2v: Add -o rhv-upload output mode.
- [PATCH FOR DISCUSSION ONLY] v2v: Add -o kubevirt output mode.