diff mbox series

[ptest-runner] main.c: Add print_helptext() for detailed help

Message ID 61615a15a0fbc852291cf2852972ce38b700ffd7.1751650751.git.joerg.sommer@navimatix.de
State New
Headers show
Series [ptest-runner] main.c: Add print_helptext() for detailed help | expand

Commit Message

Jörg Sommer July 4, 2025, 5:41 p.m. UTC
From: Natalie Dobrick <nata.dobrick@gmail.com>

The flag -h should give a more detailed message to understand the usage of
the flags.

Signed-off-by: Natalie Dobrick <nata.dobrick@gmail.com>
Signed-off-by: Jörg Sommer <joerg.sommer@navimatix.de>
---
 main.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)


Feel free to amend the help message. It's only a suggestion to give a better user experience.

Comments

Anibal Limon July 5, 2025, 2:20 p.m. UTC | #1
Hi Jörg, Nata,

Applied,

Thanks!,
Anibal

On Fri, Jul 4, 2025 at 11:41 AM Jörg Sommer <joerg.sommer@navimatix.de>
wrote:

> From: Natalie Dobrick <nata.dobrick@gmail.com>
>
> The flag -h should give a more detailed message to understand the usage of
> the flags.
>
> Signed-off-by: Natalie Dobrick <nata.dobrick@gmail.com>
> Signed-off-by: Jörg Sommer <joerg.sommer@navimatix.de>
> ---
>  main.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
>
>
> Feel free to amend the help message. It's only a suggestion to give a
> better user experience.
>
>
> diff --git a/main.c b/main.c
> index feb0685..594d198 100644
> --- a/main.c
> +++ b/main.c
> @@ -51,6 +51,26 @@ print_usage(FILE *stream, char *progname)
>                         " [-x xml-filename] [-h] [ptest1 ptest2 ...]\n",
> progname);
>  }
>
> +static inline void
> +print_help(FILE *stream, char *progname)
> +{
> +       print_usage(stream, progname);
> +       fprintf(stream,
> +               "\n  Runs all Yocto/Openembedded ptests installed in "
> DEFAULT_DIRECTORY
> +               "/*/ptest/run-ptest by default.\n\n"
> +               "Options:\n\n"
> +               "  -d DIRS              Load tests from one or more
> directories. (default: " DEFAULT_DIRECTORY ")\n"
> +               "                       DIRS must be a list separated by
> spaces.\n"
> +               "  -e NAMES             Exclude specified tests from
> execution.\n"
> +               "                       NAMES must be a list separated by
> spaces.\n"
> +               "  -h                   This help message.\n"
> +               "  -l                   List all available tests and
> exit.\n"
> +               "  -t SECONDS           Set a timeout (in seconds) for
> each test. (default: %d)\n"
> +               "  -x FILE              Write test results to an XML
> file.\n"
> +               "\n", DEFAULT_TIMEOUT
> +       );
> +}
> +
>  static char **
>  str2array(char *str, const char *delim, int *num)
>  {
> @@ -148,7 +168,7 @@ main(int argc, char *argv[])
>                                 opts.timeout = (unsigned int) atoi(optarg);
>                         break;
>                         case 'h':
> -                               print_usage(stdout, argv[0]);
> +                               print_help(stdout, argv[0]);
>                                 exit(0);
>                         /* break; not needed, not reachable after exit() */
>                         case 'x':
> --
> 2.48.1
>
>
diff mbox series

Patch

diff --git a/main.c b/main.c
index feb0685..594d198 100644
--- a/main.c
+++ b/main.c
@@ -51,6 +51,26 @@  print_usage(FILE *stream, char *progname)
 			" [-x xml-filename] [-h] [ptest1 ptest2 ...]\n", progname);
 }
 
+static inline void
+print_help(FILE *stream, char *progname)
+{
+	print_usage(stream, progname);
+	fprintf(stream,
+		"\n  Runs all Yocto/Openembedded ptests installed in " DEFAULT_DIRECTORY
+		"/*/ptest/run-ptest by default.\n\n"
+		"Options:\n\n"
+		"  -d DIRS              Load tests from one or more directories. (default: " DEFAULT_DIRECTORY ")\n"
+		"                       DIRS must be a list separated by spaces.\n"
+		"  -e NAMES             Exclude specified tests from execution.\n"
+		"                       NAMES must be a list separated by spaces.\n"
+		"  -h                   This help message.\n"
+		"  -l                   List all available tests and exit.\n"
+		"  -t SECONDS           Set a timeout (in seconds) for each test. (default: %d)\n"
+		"  -x FILE              Write test results to an XML file.\n"
+		"\n", DEFAULT_TIMEOUT
+	);
+}
+
 static char **
 str2array(char *str, const char *delim, int *num)
 {
@@ -148,7 +168,7 @@  main(int argc, char *argv[])
 				opts.timeout = (unsigned int) atoi(optarg);
 			break;
 			case 'h':
-				print_usage(stdout, argv[0]);
+				print_help(stdout, argv[0]);
 				exit(0);
 			/* break; not needed, not reachable after exit() */
 			case 'x':