[CRIU] [PATCH 04/20] compel: tell user what's wrong with usage
Kir Kolyshkin
kir at openvz.org
Thu Dec 8 01:44:17 PST 2016
In case our command line is not good, it's not enough to just show
usage info -- it is much better to explicitly say what's wrong.
Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
compel/src/main.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/compel/src/main.c b/compel/src/main.c
index 8a2df00..a2e9a56 100644
--- a/compel/src/main.c
+++ b/compel/src/main.c
@@ -163,6 +163,8 @@ int main(int argc, char *argv[])
}
}
if (!current_cflags) {
+ fprintf(stderr, "Error: unknown arch '%s'\n",
+ optarg);
return usage(1);
}
break;
@@ -205,12 +207,14 @@ int main(int argc, char *argv[])
}
if (optind >= argc) {
+ fprintf(stderr, "Error: action argument required\n");
return usage(1);
}
action = argv[optind++];
if (!strcmp(action, "cflags")) {
if (!current_cflags) {
+ fprintf(stderr, "Error: option --arch required\n");
return usage(1);
}
printf("%s", current_cflags);
@@ -224,14 +228,17 @@ int main(int argc, char *argv[])
if (!strcmp(action, "hgen")) {
if (!opts.input_filename) {
+ fprintf(stderr, "Error: option --file required\n");
return usage(1);
}
if (!opts.output_filename) {
+ fprintf(stderr, "Error: option --output required\n");
return usage(1);
}
compel_log_init(&cli_log, log_level);
return piegen();
}
+ fprintf(stderr, "Error: unknown action '%s'\n", action);
return usage(1);
}
--
2.7.4
More information about the CRIU
mailing list