From 6044dc28dc89ba31c677a20375862e3566573139 Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Sat, 19 Apr 2014 12:37:17 +0200 Subject: [PATCH] native: add help option Closes: #840 --- cpu/native/startup.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cpu/native/startup.c b/cpu/native/startup.c index 8620f8329f..432760dc23 100644 --- a/cpu/native/startup.c +++ b/cpu/native/startup.c @@ -162,7 +162,10 @@ void usage_exit() real_printf(" [-d] [-e|-E] [-o]\n"); + real_printf(" help: %s -h\n", _progname); + real_printf("\nOptions:\n\ +-h help\n\ -d daemonize\n\ -e redirect stderr to file\n\ -E do not redirect stderr (i.e. leave sterr unchanged despite socket/daemon io)\n\ @@ -203,7 +206,13 @@ __attribute__((constructor)) static void startup(int argc, char **argv) #endif #ifdef MODULE_NATIVENET - if (argc < 2) { + if ( + (argc < 2) + || ( + (strcmp("-h", argv[argp]) == 0) + || (strcmp("--help", argv[argp]) == 0) + ) + ) { usage_exit(); } argp++; @@ -211,7 +220,10 @@ __attribute__((constructor)) static void startup(int argc, char **argv) for (; argp < argc; argp++) { char *arg = argv[argp]; - if (strcmp("-d", arg) == 0) { + if ((strcmp("-h", arg) == 0) || (strcmp("--help", arg) == 0)) { + usage_exit(); + } + else if (strcmp("-d", arg) == 0) { daemonize(); if (strcmp(stdiotype, "stdio") == 0) { stdiotype = "null";