From 871a7bd73b217f799d3bc302f1fe5a03d0af08c5 Mon Sep 17 00:00:00 2001 From: Aaron Ball Date: Tue, 28 Jun 2022 18:02:17 -0600 Subject: Improve usage helptext and add -h,--help arg --- src/main.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 3a9245d..9d6415a 100644 --- a/src/main.c +++ b/src/main.c @@ -22,14 +22,25 @@ #include "runconfig.h" void usage() { - fputs("Usage:\n react-tcp-down \n\n", stderr); + fputs( + "Usage:\n" + " react-tcp-down --ip --port --cmd \n\n" + "Arguments:\n" + " -i,--ip IP Address to check for port availability\n" + " -p,--port Port to check\n" + " -c,--cmd Command to run if port is down\n" + " -h,--help Print this help text\n" + , stderr); } int parse_args(struct runconfig* cfg, int argc, char* argv[]) { int i = 0; int status = 0; while(i < argc) { - if(strcmp(argv[i], "--ip") == 0 || strcmp(argv[i], "-i") == 0) { + if(strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) { + usage(); + return 1; + } else if(strcmp(argv[i], "--ip") == 0 || strcmp(argv[i], "-i") == 0) { i++; strcpy(cfg->ip, argv[i]); -- cgit v1.2.3