ws has a --version option

This commit is contained in:
Benjamin Sergeant
2019-09-30 17:31:33 -07:00
parent a95cf727b1
commit e023dd9c36
4 changed files with 18 additions and 3 deletions

View File

@ -15,6 +15,7 @@
#include <ixcore/utils/IXCoreLogger.h>
#include <ixwebsocket/IXNetSystem.h>
#include <ixwebsocket/IXSocket.h>
#include <ixwebsocket/IXUserAgent.h>
#include <spdlog/spdlog.h>
#include <sstream>
#include <string>
@ -39,7 +40,6 @@ int main(int argc, char** argv)
}
CLI::App app {"ws is a websocket tool"};
app.require_subcommand();
std::string url("ws://127.0.0.1:8008");
std::string path;
@ -79,6 +79,7 @@ int main(int argc, char** argv)
bool greetings = false;
bool binaryMode = false;
bool redirect = false;
bool version = false;
int port = 8008;
int redisPort = 6379;
int statsdPort = 8125;
@ -103,6 +104,8 @@ int main(int argc, char** argv)
"A (comma/space/colon) separated list of ciphers to use for TLS");
};
app.add_flag("--version", version, "Connection url");
CLI::App* sendApp = app.add_subcommand("send", "Send a file");
sendApp->add_option("url", url, "Connection url")->required();
sendApp->add_option("path", path, "Path to the file to send")
@ -402,6 +405,14 @@ int main(int argc, char** argv)
{
ret = ix::ws_redis_server_main(port, hostname);
}
else if (version)
{
std::cout << "ws " << ix::userAgent() << std::endl;
}
else
{
std::cerr << "A subcommand or --version is required" << std::endl;
}
ix::uninitNetSystem();
return ret;