diff options
-rw-r--r-- | src/main.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -22,14 +22,25 @@ #include "runconfig.h" void usage() { - fputs("Usage:\n react-tcp-down <host_ip> <port> <command>\n\n", stderr); + fputs( + "Usage:\n" + " react-tcp-down --ip <host_ip> --port <port> --cmd <command>\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]); |