diff --git a/clients/shmem/villas-shmem.cpp b/clients/shmem/villas-shmem.cpp index 41bfefaf0..5890ed710 100644 --- a/clients/shmem/villas-shmem.cpp +++ b/clients/shmem/villas-shmem.cpp @@ -36,17 +36,20 @@ #include #include #include +#include using namespace villas; static std::atomic stop(false); -void usage() +static void usage() { std::cout << "Usage: villas-test-shmem WNAME VECTORIZE" << std::endl << " WNAME name of the shared memory object for the output queue" << std::endl << " RNAME name of the shared memory object for the input queue" << std::endl << " VECTORIZE maximum number of samples to read/write at a time" << std::endl; + + print_copyright(); } void quit(int, siginfo_t*, void*) diff --git a/src/villas-node.cpp b/src/villas-node.cpp index 0d6c579fa..2240a543e 100644 --- a/src/villas-node.cpp +++ b/src/villas-node.cpp @@ -111,8 +111,6 @@ static void usage() std::cout << std::endl; print_copyright(); - - exit(EXIT_FAILURE); } int main(int argc, char *argv[]) @@ -124,8 +122,10 @@ int main(int argc, char *argv[]) try { /* Check arguments */ #ifdef ENABLE_OPAL_ASYNC - if (argc != 4) - usage(argv[0]); + if (argc != 4) { + usage(); + exit(EXIT_FAILURE); + } opal_register_region(argc, argv); diff --git a/src/villas-relay.cpp b/src/villas-relay.cpp index b5d2e2b00..7cf78e793 100644 --- a/src/villas-relay.cpp +++ b/src/villas-relay.cpp @@ -388,17 +388,16 @@ int protocol_cb(lws *wsi, enum lws_callback_reasons reason, void *user, void *in return 0; } -void usage() +static void usage() { - std::cout << "Usage: villas-relay [OPTIONS]" << std::endl; - std::cout << " OPTIONS is one or more of the following options:" << std::endl; - std::cout << " -d LVL set debug level" << std::endl; - std::cout << " -p PORT the port number to listen on" << std::endl; - std::cout << " -P PROT the websocket protocol" << std::endl; - std::cout << " -l enable loopback of own data" << std::endl; - std::cout << " -V show version and exit" << std::endl; - std::cout << " -h show usage and exit" << std::endl; - std::cout << std::endl; + std::cout << "Usage: villas-relay [OPTIONS]" << std::endl + << " OPTIONS is one or more of the following options:" << std::endl + << " -d LVL set debug level" << std::endl + << " -p PORT the port number to listen on" << std::endl + << " -P PROT the websocket protocol" << std::endl + << " -l enable loopback of own data" << std::endl + << " -V show version and exit" << std::endl + << " -h show usage and exit" << std::endl << std::endl; villas::print_copyright(); } diff --git a/src/villas-signal.cpp b/src/villas-signal.cpp index 0737699bc..c215f9e89 100644 --- a/src/villas-signal.cpp +++ b/src/villas-signal.cpp @@ -46,6 +46,33 @@ using namespace villas; static std::atomic stop(false); +static void usage() +{ + std::cout << "Usage: villas-signal [OPTIONS] SIGNAL" << std::endl + << " SIGNAL is on of the following signal types:" << std::endl + << " mixed" << std::endl + << " random" << std::endl + << " sine" << std::endl + << " triangle" << std::endl + << " square" << std::endl + << " ramp" << std::endl + << " constants" << std::endl + << " counter" << std::endl << std::endl + << " OPTIONS is one or more of the following options:" << std::endl + << " -d LVL set debug level" << std::endl + << " -f FMT set the format" << std::endl + << " -v NUM specifies how many values a message should contain" << std::endl + << " -r HZ how many messages per second" << std::endl + << " -n non real-time mode. do not throttle output." << std::endl + << " -F HZ the frequency of the signal" << std::endl + << " -a FLT the amplitude" << std::endl + << " -D FLT the standard deviation for 'random' signals" << std::endl + << " -o OFF the DC bias" << std::endl + << " -l NUM only send LIMIT messages and stop" << std::endl << std::endl; + + print_copyright(); +} + json_t * parse_cli(int argc, char *argv[]) { Logger logger = logging.get("signal"); @@ -64,7 +91,7 @@ json_t * parse_cli(int argc, char *argv[]) /* Parse optional command line arguments */ int c; char *endptr; - while ((c = getopt(argc, argv, "v:r:f:l:a:D:no:d:")) != -1) { + while ((c = getopt(argc, argv, "v:r:f:l:a:D:no:d:hV")) != -1) { switch (c) { case 'n': rt = 0; @@ -102,8 +129,14 @@ json_t * parse_cli(int argc, char *argv[]) logging.setLevel(optarg); break; + case 'V': + print_version(); + exit(EXIT_SUCCESS); + + case 'h': case '?': - break; + usage(); + exit(c == '?' ? EXIT_FAILURE : EXIT_SUCCESS); } continue; @@ -131,33 +164,6 @@ check: if (optarg == endptr) ); } -void usage() -{ - std::cout << "Usage: villas-signal [OPTIONS] SIGNAL" << std::endl - << " SIGNAL is on of the following signal types:" << std::endl - << " mixed" << std::endl - << " random" << std::endl - << " sine" << std::endl - << " triangle" << std::endl - << " square" << std::endl - << " ramp" << std::endl - << " constants" << std::endl - << " counter" << std::endl << std::endl - << " OPTIONS is one or more of the following options:" << std::endl - << " -d LVL set debug level" << std::endl - << " -f FMT set the format" << std::endl - << " -v NUM specifies how many values a message should contain" << std::endl - << " -r HZ how many messages per second" << std::endl - << " -n non real-time mode. do not throttle output." << std::endl - << " -F HZ the frequency of the signal" << std::endl - << " -a FLT the amplitude" << std::endl - << " -D FLT the standard deviation for 'random' signals" << std::endl - << " -o OFF the DC bias" << std::endl - << " -l NUM only send LIMIT messages and stop" << std::endl << std::endl; - - print_copyright(); -} - static void quit(int signal, siginfo_t *sinfo, void *ctx) { Logger logger = logging.get("signal"); diff --git a/src/villas-test-cmp.cpp b/src/villas-test-cmp.cpp index ab9ca1314..942fa3522 100644 --- a/src/villas-test-cmp.cpp +++ b/src/villas-test-cmp.cpp @@ -90,7 +90,7 @@ public: } }; -void usage() +static void usage() { std::cout << "Usage: villas-test-cmp [OPTIONS] FILE1 FILE2 ... FILEn" << std::endl << " FILE a list of files to compare" << std::endl diff --git a/src/villas-test-rtt.cpp b/src/villas-test-rtt.cpp index 00240c218..c06ccb14a 100644 --- a/src/villas-test-rtt.cpp +++ b/src/villas-test-rtt.cpp @@ -54,7 +54,7 @@ void quit(int signal, siginfo_t *sinfo, void *ctx) stop = true; } -void usage() +static void usage() { std::cout << "Usage: villas-test-rtt [OPTIONS] CONFIG NODE" << std::endl << " CONFIG path to a configuration file" << std::endl @@ -101,7 +101,7 @@ int main(int argc, char *argv[]) /* Parse Arguments */ int c; char *endptr; - while ((c = getopt (argc, argv, "w:h:r:f:c:b:Vd:")) != -1) { + while ((c = getopt (argc, argv, "w:hr:f:c:b:Vd:")) != -1) { switch (c) { case 'c': count = strtoul(optarg, &endptr, 10); diff --git a/tools/villas.sh b/tools/villas.sh index d46f090bc..a6dc29bfb 100755 --- a/tools/villas.sh +++ b/tools/villas.sh @@ -40,12 +40,13 @@ ARGS=${@:2} # Check if tool is available if ! [[ "$TOOL" =~ $(echo ^\($TOOLS\)$) ]]; then - echo "Usage: villas [TOOL]" 1>&2 + echo "Usage: villas [TOOL]" echo " TOOL is one of ${TOOLS}" echo - echo "For detailed documentation, please run 'villas node'" - echo " and point your web browser to http://localhost:80" + echo "For detailed documentation, please see: 'villas node'" + echo " http://villas.fein-aachen.org/doc/" echo + # Show VILLASnode copyright and contact info villas-node -h | tail -n3 exit 1