| 48 | } |
| 49 | |
| 50 | String CommandProcessor::help(ConnectionId connectionId, String const& argumentString) { |
| 51 | auto arguments = m_parser.tokenizeToStringList(argumentString); |
| 52 | |
| 53 | auto assets = Root::singleton().assets(); |
| 54 | auto basicCommands = assets->json("/help.config:basicCommands"); |
| 55 | auto openSbCommands = assets->json("/help.config:openSbCommands"); |
| 56 | auto adminCommands = assets->json("/help.config:adminCommands"); |
| 57 | auto debugCommands = assets->json("/help.config:debugCommands"); |
| 58 | auto openSbDebugCommands = assets->json("/help.config:openSbDebugCommands"); |
| 59 | |
| 60 | if (arguments.size()) { |
| 61 | if (arguments.size() >= 1) { |
| 62 | if (auto helpText = basicCommands.optString(arguments[0]).orMaybe(openSbCommands.optString(arguments[0])).orMaybe(adminCommands.optString(arguments[0])).orMaybe(debugCommands.optString(arguments[0])).orMaybe(openSbDebugCommands.optString(arguments[0]))) |
| 63 | return *helpText; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | String res = ""; |
| 68 | |
| 69 | auto commandDescriptions = [&](Json const& commandConfig) { |
| 70 | StringList commandList = commandConfig.toObject().keys(); |
| 71 | sort(commandList); |
| 72 | return "/" + commandList.join(", /"); |
| 73 | }; |
| 74 | |
| 75 | String basicHelpFormat = assets->json("/help.config:basicHelpText").toString(); |
| 76 | res = res + strf(basicHelpFormat.utf8Ptr(), commandDescriptions(basicCommands)); |
| 77 | |
| 78 | String openSbHelpFormat = assets->json("/help.config:openSbHelpText").toString(); |
| 79 | res = res + "\n" + strf(openSbHelpFormat.utf8Ptr(), commandDescriptions(openSbCommands)); |
| 80 | |
| 81 | if (!adminCheck(connectionId, "")) { |
| 82 | String adminHelpFormat = assets->json("/help.config:adminHelpText").toString(); |
| 83 | res = res + "\n" + strf(adminHelpFormat.utf8Ptr(), commandDescriptions(adminCommands)); |
| 84 | |
| 85 | String debugHelpFormat = assets->json("/help.config:debugHelpText").toString(); |
| 86 | res = res + "\n" + strf(debugHelpFormat.utf8Ptr(), commandDescriptions(debugCommands)); |
| 87 | |
| 88 | String openSbDebugHelpFormat = assets->json("/help.config:openSbDebugHelpText").toString(); |
| 89 | res = res + "\n" + strf(openSbDebugHelpFormat.utf8Ptr(), commandDescriptions(openSbDebugCommands)); |
| 90 | } |
| 91 | |
| 92 | res = res + "\n" + basicCommands.getString("help"); |
| 93 | |
| 94 | return res; |
| 95 | } |
| 96 | |
| 97 | String CommandProcessor::admin(ConnectionId connectionId, String const&) { |
| 98 | auto config = Root::singleton().configuration(); |
nothing calls this directly
no test coverage detected