From c1788c4e433eda5b55c0182016c5ea9ddda4e9dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Thu, 27 Apr 2017 17:20:10 +0200 Subject: [PATCH] top: add module description & usage --- src/systemcmds/top/top.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/systemcmds/top/top.c b/src/systemcmds/top/top.c index 6de022e9a0..99a402f490 100644 --- a/src/systemcmds/top/top.c +++ b/src/systemcmds/top/top.c @@ -50,12 +50,22 @@ #include #include #include +#include /** * Start the top application. */ __EXPORT int top_main(int argc, char *argv[]); + +static void print_usage(void) +{ + PRINT_MODULE_DESCRIPTION("Monitor running processes and their CPU, stack usage, priority and state"); + + PRINT_MODULE_USAGE_NAME_SIMPLE("top", "system"); + PRINT_MODULE_USAGE_COMMAND_DESCR("once", "print load only once"); +} + int top_main(int argc, char *argv[]) { @@ -67,10 +77,16 @@ top_main(int argc, char *argv[]) /* clear screen */ dprintf(1, "\033[2J\n"); - if (argc > 1 && !strcmp(argv[1], "once")) { - print_load(curr_time, 1, &load); - sleep(1); - print_load(hrt_absolute_time(), 1, &load); + if (argc > 1) { + if (!strcmp(argv[1], "once")) { + print_load(curr_time, 1, &load); + sleep(1); + print_load(hrt_absolute_time(), 1, &load); + + } else { + print_usage(); + } + return 0; }