Show current RPC input more clearly
Change-Id: Ibc1c8802b814bbe860b4af433c13c712a08fe3d5
diff --git a/src/cli.cpp b/src/cli.cpp
index a2c9cdc..5a9de67 100644
--- a/src/cli.cpp
+++ b/src/cli.cpp
@@ -6,6 +6,7 @@
*
*/
#include <atomic>
+#include <boost/algorithm/string.hpp>
#include <docopt.h>
#include <iostream>
#include <optional>
@@ -227,7 +228,18 @@
}
while (backendReturnCode == 0) {
- auto line = lineEditor.input(parser.currentNode() + "> ");
+ auto fullContextPath = parser.currentNode();
+ std::string prompt;
+ if (auto activeRpcPath = proxyDatastore.inputDatastorePath()) {
+ auto rpcPrefixLength = activeRpcPath->size();
+ prompt = "(prepare: " + *activeRpcPath + ") " + fullContextPath.substr(rpcPrefixLength);
+ } else {
+ prompt = fullContextPath;
+ }
+
+ prompt += "> ";
+
+ auto line = lineEditor.input(prompt);
if (!line) {
// If user pressed CTRL-C to abort the line, errno gets set to EAGAIN.
// If user pressed CTRL-D (for EOF), errno doesn't get set to EAGAIN, so we exit the program.