MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / help

Method help

src/rpc/server.cpp:153–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151 */
152
153std::string CRPCTable::help(const std::string& strCommand, const JSONRPCRequest& helpreq) const
154{
155 std::string strRet;
156 std::string category;
157 std::set<rpcfn_type> setDone;
158 std::vector<std::pair<std::string, const CRPCCommand*> > vCommands;
159
160 for (const auto& entry : mapCommands)
161 vCommands.push_back(make_pair(entry.second->category + entry.first, entry.second));
162 sort(vCommands.begin(), vCommands.end());
163
164 JSONRPCRequest jreq(helpreq);
165 jreq.fHelp = true;
166 jreq.params = UniValue();
167
168 for (const std::pair<std::string, const CRPCCommand*>& command : vCommands)
169 {
170 const CRPCCommand *pcmd = command.second;
171 std::string strMethod = pcmd->name;
172 if ((strCommand != "" || pcmd->category == "hidden") && strMethod != strCommand)
173 continue;
174 jreq.strMethod = strMethod;
175 try
176 {
177 rpcfn_type pfn = pcmd->actor;
178 if (setDone.insert(pfn).second)
179 (*pfn)(jreq);
180 }
181 catch (const std::exception& e)
182 {
183 // Help text is returned in an exception
184 std::string strHelp = std::string(e.what());
185 if (strCommand == "")
186 {
187 if (strHelp.find('\n') != std::string::npos)
188 strHelp = strHelp.substr(0, strHelp.find('\n'));
189
190 if (category != pcmd->category)
191 {
192 if (!category.empty())
193 strRet += "\n";
194 category = pcmd->category;
195 std::string firstLetter = category.substr(0,1);
196 boost::to_upper(firstLetter);
197 strRet += "== " + firstLetter + category.substr(1) + " ==\n";
198 }
199 }
200 strRet += strHelp + "\n";
201 }
202 }
203 if (strRet == "")
204 strRet = strprintf("help: unknown command: %s\n", strCommand);
205 strRet = strRet.substr(0,strRet.size()-1);
206 return strRet;
207}
208
209UniValue help(const JSONRPCRequest& jsonRequest)
210{

Callers 5

run_testMethod · 0.80
test_categoriesMethod · 0.80
dump_helpMethod · 0.80
write_all_rpc_commandsFunction · 0.80
helpFunction · 0.80

Calls 9

whatMethod · 0.80
UniValueClass · 0.70
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
findMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by 1

test_categoriesMethod · 0.64