Skip to content
Snippets Groups Projects
Commit 54277dec authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Display usage help when unrecognized param is detected

Include -pause and -loop options in usage help output.

Don't delay (sleep) one second when looping and -pause option is used.

Flush the output before waiting for key-press (-pause option is used).

This should all address issue #365. Sorry for the long wait.
parent a71a2044
No related branches found
No related tags found
1 merge request!455Update branch with changes from master
Pipeline #6536 failed
...@@ -452,32 +452,8 @@ void printnodedat(int number, node_t node) ...@@ -452,32 +452,8 @@ void printnodedat(int number, node_t node)
printf(" %d error%c",node.errors, node.errors>1 ? 's' : '\0' ); printf(" %d error%c",node.errors, node.errors>1 ? 's' : '\0' );
} }
void usage()
/****************************/
/* Main program entry point */
/****************************/
int main(int argc, char **argv)
{ {
char str[256],ctrl_dir[MAX_PATH + 1],debug=0;
int sys_nodes,node_num=0,onoff=0;
int i,j,mode=0,misc;
int modify=0;
int loop=0;
int pause=0;
long value=0;
node_t node;
bool verbose = false;
str_list_t key_list = strListInit();
printf("\nSynchronet Node Display/Control Utility v%s\n\n", VERSION);
if(sizeof(node_t)!=SIZEOF_NODE_T) {
printf("COMPILER ERROR: sizeof(node_t)=%" XP_PRIsize_t "u instead of %d\n"
,sizeof(node_t),SIZEOF_NODE_T);
return(-1);
}
if(argc<2) {
printf("usage: node [-v[key]] [-debug] [action [on|off]] [node numbers] [...]" printf("usage: node [-v[key]] [-debug] [action [on|off]] [node numbers] [...]"
"\n\n"); "\n\n");
printf("actions (default action is 'list'):\n\n"); printf("actions (default action is 'list'):\n\n");
...@@ -503,11 +479,41 @@ int main(int argc, char **argv) ...@@ -503,11 +479,41 @@ int main(int argc, char **argv)
printf("\n"); printf("\n");
printf("options:\n\n"); printf("options:\n\n");
printf(" -debug = display numeric values of each node record field\n"); printf(" -debug = display numeric values of each node record field\n");
printf(" -loop = execute node command repeatedly\n");
printf(" -pause = wait for a key-press after executing node command\n");
printf(" -v[key] = view a connected-client key value (default: all)\n"); printf(" -v[key] = view a connected-client key value (default: all)\n");
printf(" (may be used multiple times to display multiple keys)\n"); printf(" (may be used multiple times to display multiple keys)\n");
exit(0); exit(0);
} }
/****************************/
/* Main program entry point */
/****************************/
int main(int argc, char **argv)
{
char str[256],ctrl_dir[MAX_PATH + 1],debug=0;
int sys_nodes,node_num=0,onoff=0;
int i,j,mode=0,misc;
int modify=0;
int loop=0;
int pause=0;
long value=0;
node_t node;
bool verbose = false;
str_list_t key_list = strListInit();
printf("\nSynchronet Node Display/Control Utility v%s\n\n", VERSION);
if(sizeof(node_t)!=SIZEOF_NODE_T) {
printf("COMPILER ERROR: sizeof(node_t)=%" XP_PRIsize_t "u instead of %d\n"
,sizeof(node_t),SIZEOF_NODE_T);
return(-1);
}
if(argc<2) {
usage();
}
SAFECOPY(ctrl_dir, get_ctrl_dir(/* warn: */TRUE)); SAFECOPY(ctrl_dir, get_ctrl_dir(/* warn: */TRUE));
if(ctrl_dir[strlen(ctrl_dir)-1]!='\\' if(ctrl_dir[strlen(ctrl_dir)-1]!='\\'
&& ctrl_dir[strlen(ctrl_dir)-1]!='/') && ctrl_dir[strlen(ctrl_dir)-1]!='/')
...@@ -535,11 +541,11 @@ int main(int argc, char **argv) ...@@ -535,11 +541,11 @@ int main(int argc, char **argv)
node_num=onoff=value=0; node_num=onoff=value=0;
if(!stricmp(argv[i],"-DEBUG")) if(!stricmp(argv[i],"-DEBUG"))
debug=1; debug=1;
if(!stricmp(argv[i],"-LOOP")) else if(!stricmp(argv[i],"-LOOP"))
loop=1; loop=1;
if(!stricmp(argv[i],"-PAUSE")) else if(!stricmp(argv[i],"-PAUSE"))
pause=1; pause=1;
if(strncmp(argv[i], "-v", 2) == 0) { else if(strncmp(argv[i], "-v", 2) == 0) {
verbose = true; verbose = true;
if(argv[i][2]) if(argv[i][2])
strListPush(&key_list, argv[i] + 2); strListPush(&key_list, argv[i] + 2);
...@@ -596,6 +602,7 @@ int main(int argc, char **argv) ...@@ -596,6 +602,7 @@ int main(int argc, char **argv)
mode=MODE_EXTAUX; mode=MODE_EXTAUX;
value=strtoul(argv[i]+7, NULL, 0); value=strtoul(argv[i]+7, NULL, 0);
} }
else usage();
} }
if(mode!=MODE_LIST) if(mode!=MODE_LIST)
modify=1; modify=1;
...@@ -705,12 +712,14 @@ int main(int argc, char **argv) ...@@ -705,12 +712,14 @@ int main(int argc, char **argv)
} /* if(!node_num) */ } /* if(!node_num) */
if(pause) { if(pause) {
printf("Hit enter..."); printf("\nHit enter...");
fflush(stdout);
getchar(); getchar();
printf("\n"); printf("\n");
} }
if(!loop) if(!loop)
break; break;
if(!pause)
SLEEP(1000); SLEEP(1000);
cls(); cls();
} /* while(1) */ } /* while(1) */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment