| 122 | |
| 123 | |
| 124 | void CCommandTree::PrintHelpFor(const wxString& command) const |
| 125 | { |
| 126 | wxString cmd = command.BeforeFirst(' ').Lower(); |
| 127 | if (!cmd.IsEmpty()) { |
| 128 | for (CmdPosConst_t it = m_subcommands.begin(); it != m_subcommands.end(); ++it) { |
| 129 | if ((*it)->m_command.Lower() == cmd) { |
| 130 | (*it)->PrintHelpFor(command.AfterFirst(' ').Trim(false)); |
| 131 | return; |
| 132 | } |
| 133 | } |
| 134 | if (m_parent) { |
| 135 | m_app->Show(CFormat(_("Unknown extension '%s' for the '%s' command.\n")) % command % GetFullCommand()); |
| 136 | } else { |
| 137 | m_app->Show(CFormat(_("Unknown command '%s'.\n")) % command); |
| 138 | } |
| 139 | } else { |
| 140 | wxString fullcmd = GetFullCommand(); |
| 141 | if (!fullcmd.IsEmpty()) { |
| 142 | m_app->Show(fullcmd.Upper() + ": " + wxGetTranslation(m_short) + "\n"); |
| 143 | if (!m_verbose.IsEmpty()) { |
| 144 | m_app->Show("\n"); |
| 145 | m_app->Show(wxGetTranslation(m_verbose)); |
| 146 | } |
| 147 | } |
| 148 | if (m_params == CMD_PARAM_NEVER) { |
| 149 | m_app->Show(_("\nThis command cannot have an argument.\n")); |
| 150 | } else if (m_params == CMD_PARAM_ALWAYS) { |
| 151 | m_app->Show(_("\nThis command must have an argument.\n")); |
| 152 | } |
| 153 | if (m_cmd_id == CMD_ERR_INCOMPLETE) { |
| 154 | m_app->Show(_("\nThis command is incomplete, you must use one of the extensions below.\n")); |
| 155 | } |
| 156 | if (!m_subcommands.empty()) { |
| 157 | CmdPosConst_t it; |
| 158 | int maxlen = 0; |
| 159 | if (m_parent) { |
| 160 | m_app->Show(_("\nAvailable extensions:\n")); |
| 161 | } else { |
| 162 | m_app->Show(_("Available commands:\n")); |
| 163 | } |
| 164 | for (it = m_subcommands.begin(); it != m_subcommands.end(); ++it) { |
| 165 | if (!((*it)->m_cmd_id >= 0 && (*it)->m_cmd_id & CMD_DEPRECATED) || m_parent) { |
| 166 | int len = (*it)->m_command.Length(); |
| 167 | if (len > maxlen) { |
| 168 | maxlen = len; |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | maxlen += 4; |
| 173 | for (it = m_subcommands.begin(); it != m_subcommands.end(); ++it) { |
| 174 | if (!((*it)->m_cmd_id >= 0 && (*it)->m_cmd_id & CMD_DEPRECATED) || m_parent) { |
| 175 | m_app->Show((*it)->m_command + wxString(' ', maxlen - (*it)->m_command.Length()) + wxGetTranslation((*it)->m_short) + "\n"); |
| 176 | } |
| 177 | } |
| 178 | if (!m_parent) { |
| 179 | m_app->Show(CFormat(_("\nAll commands are case insensitive.\nType '%s <command>' to get detailed info on <command>.\n")) % "help"); |
| 180 | } |
| 181 | } |