From c2bd042ef10fa29e382f69ce2f78d30ead87e6ba Mon Sep 17 00:00:00 2001 From: kanurag94 Date: Tue, 19 May 2020 14:37:42 +0530 Subject: [PATCH] Hide help message on errors --- src/ui/main.cpp | 6 +++++- src/util/xmenu.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ui/main.cpp b/src/ui/main.cpp index 6c07a9a8..9314972b 100644 --- a/src/ui/main.cpp +++ b/src/ui/main.cpp @@ -102,11 +102,12 @@ int ui_params_parser(int argc, char **argv) int is; const struct params *par = NULL; int error = 0; + int show_help = 0; int found; for (i = 1; i < argc && !error; i++) { found = 0; if (!strcmp("-help", argv[i])) { - error = 1; + show_help = 1; break; } for (d = 0; d < nparams; d++) { @@ -182,6 +183,9 @@ int ui_params_parser(int argc, char **argv) i = ie; } if (error) { + return 0; + } + if (show_help) { const char *name[] = {"", "number", "string", "f.point"}; printf(" XaoS" XaoS_VERSION " help text\n\n"); printf("option string param description\n\n"); diff --git a/src/util/xmenu.cpp b/src/util/xmenu.cpp index a0635256..4196a56d 100644 --- a/src/util/xmenu.cpp +++ b/src/util/xmenu.cpp @@ -720,7 +720,7 @@ int menu_processargs(int n, int argc, char **argv) margv = argv; error = menu_processcommand(NULL, gettoken, 0, MENUFLAG_NOOPTION, "root"); if (error) { - x_error("%s", error); + x_error("%s\nPlease enter `xaos -help` to learn more on command line options", error); return -1; } return (argpos - 2);