diff options
author | Aaron Ball <nullspoon@oper.io> | 2022-06-28 18:02:17 -0600 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2022-06-28 18:02:17 -0600 |
commit | 871a7bd73b217f799d3bc302f1fe5a03d0af08c5 (patch) | |
tree | 85b9aa62e874c3a2480d9853a2f0b44c74eb47a4 | |
parent | 650f7ba01614f59a3e1e862d9f05b6866072c913 (diff) | |
download | react-socket-down-871a7bd73b217f799d3bc302f1fe5a03d0af08c5.tar.gz react-socket-down-871a7bd73b217f799d3bc302f1fe5a03d0af08c5.tar.xz |
Improve usage helptext and add -h,--help arg
-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]); |