diff --git a/demo/main.c b/demo/main.c index 160b097..2ef491a 100644 --- a/demo/main.c +++ b/demo/main.c @@ -20,6 +20,14 @@ #include #include +void print_help() { + puts("Use `/' at the beginning to indicate a command (like in IRC)."); + puts(" stats -- Give network statistics of the local node."); + puts(" num_nodes -- Get total number of nodes."); + puts(" exit | quit -- Close the program."); + puts(" help -- Show this help information."); +} + int main(int argc, char *argv[]) { if(argc != 2 && argc != 4) { @@ -45,16 +53,19 @@ int main(int argc, char *argv[]) { if(connect_address) NeoComm_connect(connect_address, connect_port); - while(1) { + int run = 1; + while(run) { char in[128]; printf("> "); scanf("%s", in); if(strcmp(in, "/exit") == 0 || strcmp(in, "/quit") == 0) - break; + run = 0; else if(strcmp(in, "/stats") == 0) printf("%s", NeoComm_get_node_stats()); else if(strcmp(in, "/num_nodes") == 0) printf("%u", NeoComm_count_connected_nodes()); + else if(strcmp(in, "/help") == 0) + print_help(); } NeoComm_deinit();