mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
tools: improve reporting for option errors (RHBZ#1316041)
Improve the error messages produced by C-based tools in case of issues with the command line options: - explicitly mention to use -a/-d (and -A/-D in virt-diff) - when extra arguments are found, mention the correct way to pass options to certain command line switches (like --format) - in virt-inspector, give a cleaner error message when neither -i nor any -m is specified In all the cases, keep the extra notice to use 'TOOL --help' to get more help with it.
This commit is contained in:
@@ -275,14 +275,22 @@ main (int argc, char *argv[])
|
||||
assert (live == 0);
|
||||
|
||||
/* Must be no extra arguments on the command line. */
|
||||
if (optind != argc)
|
||||
if (optind != argc) {
|
||||
fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n"
|
||||
"Make sure to specify the argument for --format or --scratch "
|
||||
"like '--format=%s'.\n"),
|
||||
guestfs_int_program_name, argv[optind], argv[optind]);
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
CHECK_OPTION_format_consumed;
|
||||
|
||||
/* User must have specified some drives. */
|
||||
if (drvs == NULL)
|
||||
if (drvs == NULL) {
|
||||
fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
|
||||
guestfs_int_program_name);
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Setting "direct mode" is required for the rescue appliance. */
|
||||
if (guestfs_set_direct (g, 1) == -1)
|
||||
|
||||
Reference in New Issue
Block a user