summaryrefslogtreecommitdiff
path: root/upstream/remote-process/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'upstream/remote-process/main.cpp')
-rw-r--r--upstream/remote-process/main.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/upstream/remote-process/main.cpp b/upstream/remote-process/main.cpp
index c0d8f51..ad94dc3 100644
--- a/upstream/remote-process/main.cpp
+++ b/upstream/remote-process/main.cpp
@@ -77,16 +77,19 @@ bool sendAndDisplayCommand(asio::generic::stream_protocol::socket &socket,
int usage(const std::string &command, const std::string &error)
{
if (not error.empty()) {
- cerr << error << endl;
+ cerr << error << endl;
}
cerr << "Usage: " << endl;
cerr << "Send a single command:" << endl;
cerr << "\t" << command
- << " <hostname port|tcp://[host]:port|unix://path> <command> [argument[s]]" << endl;
+ << " <hostname port|<protocol>://<host:port|port_name>> <command> [argument[s]]" << endl;
return 1;
}
+// <hostname port|path> command [argument[s]]
+// or
+// <hostname port|path> < commands
int main(int argc, char *argv[])
{
int commandPos;
@@ -119,24 +122,24 @@ int main(int argc, char *argv[])
const std::string tcpProtocol{"tcp"};
const std::string unixProtocol{"unix"};
- const std::vector<std::string> supportedProtocols{tcpProtocol, unixProtocol};
+ const std::vector<std::string> supportedProtocols{ tcpProtocol, unixProtocol };
const std::string protocolDelimiter{"://"};
size_t protocolDelPos = endPortArg.find(protocolDelimiter);
if (protocolDelPos == std::string::npos) {
- return usage(argv[0], "Invalid endpoint " + endPortArg);
+ return usage(argv[0], "Invalid socket endpoint, missing " + protocolDelimiter);
}
protocol = endPortArg.substr(0, protocolDelPos);
if (std::find(begin(supportedProtocols), end(supportedProtocols), protocol) ==
- end(supportedProtocols)) {
- return usage(argv[0], "Invalid endpoint " + endPortArg);
+ end(supportedProtocols)) {
+ return usage(argv[0], "Invalid socket protocol " + protocol);
}
isInet = (endPortArg.find(tcpProtocol) != std::string::npos);
if (isInet) {
- size_t portDelPos = endPortArg.rfind(':');
+ size_t portDelPos = endPortArg.find(':', protocolDelPos + protocolDelimiter.size());
if (portDelPos == std::string::npos) {
- return usage(argv[0], "Invalid endpoint " + endPortArg);
+ return usage(argv[0], "Invalid tcp endpoint" + endPortArg);
}
host = endPortArg.substr(protocolDelPos + protocolDelimiter.size(),
portDelPos - (protocolDelPos + protocolDelimiter.size()));