MCPcopy Create free account
hub / github.com/LUX-Core/lux / help

Method help

src/rpcserver.cpp:163–710  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161 */
162
163string CRPCTable::help(string strCommand) const
164{
165 string strRet;
166 string category;
167 set<rpcfn_type> setDone;
168 vector<pair<string, const CRPCCommand*> > vCommands;
169
170 for (map<string, const CRPCCommand*>::const_iterator mi = mapCommands.begin(); mi != mapCommands.end(); ++mi)
171 vCommands.push_back(make_pair(mi->second->category + mi->first, mi->second));
172 sort(vCommands.begin(), vCommands.end());
173
174 for (const PAIRTYPE(string, const CRPCCommand*) & command : vCommands) {
175 const CRPCCommand* pcmd = command.second;
176 string strMethod = pcmd->name;
177 // We already filter duplicates, but these deprecated screw up the sort order
178 if (strMethod.find("label") != string::npos)
179 continue;
180 if ((strCommand != "" || pcmd->category == "hidden") && strMethod != strCommand)
181 continue;
182 try
183 {
184 UniValue params(UniValue::VARR);
185 rpcfn_type pfn = pcmd->actor;
186 if (setDone.insert(pfn).second)
187 (*pfn)(params, true);
188 }
189 catch (const std::exception& e)
190 {
191 // Help text is returned in an exception
192 string strHelp = string(e.what());
193 if (strCommand == "") {
194 if (strHelp.find('\n') != string::npos)
195 strHelp = strHelp.substr(0, strHelp.find('\n'));
196
197 if (category != pcmd->category) {
198 if (!category.empty())
199 strRet += "\n";
200 category = pcmd->category;
201 string firstLetter = category.substr(0, 1);
202 boost::to_upper(firstLetter);
203 strRet += "== " + firstLetter + category.substr(1) + " ==\n";
204 }
205 }
206 strRet += strHelp + "\n";
207 }
208 }
209 if (strRet == "")
210 strRet = strprintf("help: unknown command: %s\n", strCommand);
211 strRet = strRet.substr(0, strRet.size() - 1);
212 return strRet;
213}
214
215UniValue help(const UniValue& params, bool fHelp)
216{
217 if (fHelp || params.size() > 1)
218 throw runtime_error(
219 "help ( \"command\" )\n"
220 "\nList all commands, or get help for a specified command.\n"

Callers 3

bitrpc.pyFile · 0.80
write_all_rpc_commandsFunction · 0.80
write_all_rpc_commandsFunction · 0.80

Calls 11

get_strMethod · 0.80
StartShutdownFunction · 0.70
helpFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
insertMethod · 0.45
whatMethod · 0.45
findMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected