@@ -136,10 +136,10 @@ class QtRPCTimerInterface: public RPCTimerInterface
136
136
#include " rpcconsole.moc"
137
137
138
138
/* *
139
- * Split shell command line into a list of arguments and execute the command(s).
139
+ * Split shell command line into a list of arguments and optionally execute the command(s).
140
140
* Aims to emulate \c bash and friends.
141
141
*
142
- * - Command nesting is possible with brackets [ example: validateaddress(getnewaddress())]
142
+ * - Command nesting is possible with parenthesis; for example: validateaddress(getnewaddress())
143
143
* - Arguments are delimited with whitespace or comma
144
144
* - Extra whitespace at the beginning and end and between arguments will be ignored
145
145
* - Text can be "double" or 'single' quoted
@@ -150,9 +150,10 @@ class QtRPCTimerInterface: public RPCTimerInterface
150
150
*
151
151
* @param[out] result stringified Result from the executed command(chain)
152
152
* @param[in] strCommand Command line to split
153
+ * @param[in] fExecute set true if you want the command to be executed
153
154
*/
154
155
155
- bool RPCConsole::RPCExecuteCommandLine (std::string &strResult, const std::string &strCommand)
156
+ bool RPCConsole::RPCParseCommandLine (std::string &strResult, const std::string &strCommand, const bool fExecute )
156
157
{
157
158
std::vector< std::vector<std::string> > stack;
158
159
stack.push_back (std::vector<std::string>());
@@ -196,7 +197,7 @@ bool RPCConsole::RPCExecuteCommandLine(std::string &strResult, const std::string
196
197
curarg += ch;
197
198
break ;
198
199
}
199
- if (curarg.size ())
200
+ if (curarg.size () && fExecute )
200
201
{
201
202
// if we have a value query, query arrays with index and objects with a string key
202
203
UniValue subelement;
@@ -271,13 +272,14 @@ bool RPCConsole::RPCExecuteCommandLine(std::string &strResult, const std::string
271
272
}
272
273
if ((ch == ' )' || ch == ' \n ' ) && stack.size () > 0 )
273
274
{
274
- std::string strPrint;
275
- // Convert argument list to JSON objects in method-dependent way,
276
- // and pass it along with the method name to the dispatcher.
277
- JSONRPCRequest req;
278
- req.params = RPCConvertValues (stack.back ()[0 ], std::vector<std::string>(stack.back ().begin () + 1 , stack.back ().end ()));
279
- req.strMethod = stack.back ()[0 ];
280
- lastResult = tableRPC.execute (req);
275
+ if (fExecute ) {
276
+ // Convert argument list to JSON objects in method-dependent way,
277
+ // and pass it along with the method name to the dispatcher.
278
+ JSONRPCRequest req;
279
+ req.params = RPCConvertValues (stack.back ()[0 ], std::vector<std::string>(stack.back ().begin () + 1 , stack.back ().end ()));
280
+ req.strMethod = stack.back ()[0 ];
281
+ lastResult = tableRPC.execute (req);
282
+ }
281
283
282
284
state = STATE_COMMAND_EXECUTED;
283
285
curarg.clear ();
0 commit comments