Make the RTFM command work as help for new users
[TortoiseGit.git] / src / TortoiseProc / Commands / Command.cpp
blob017fcdedfef3a4ee0409b8846965e002b2d0db71
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2017 - TortoiseGit
4 // Copyright (C) 2007-2009 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
21 #include "Command.h"
22 #include "MessageBox.h"
23 #include "AboutCommand.h"
24 #include "AutoTextTestCommand.h"
25 #include "CommitCommand.h"
26 #include "LogCommand.h"
28 #include "CreateRepositoryCommand.h"
29 #include "CloneCommand.h"
30 #include "PrevDiffCommand.h"
31 #include "DiffCommand.h"
33 #include "RenameCommand.h"
34 #include "RepoStatusCommand.h"
36 #include "RevertCommand.h"
37 #include "RemoveCommand.h"
38 #include "PullCommand.h"
39 #include "FetchCommand.h"
40 #include "PushCommand.h"
41 #include "BranchCommand.h"
42 #include "TagCommand.h"
43 #include "MergeCommand.h"
44 #include "SwitchCommand.h"
45 #include "ExportCommand.h"
46 #include "AddCommand.h"
47 #include "IgnoreCommand.h"
48 #include "FormatPatchCommand.h"
49 #include "ImportPatchCommand.h"
50 #include "BlameCommand.h"
51 #include "SettingsCommand.h"
52 #include "ConflictEditorCommand.h"
53 #include "CleanupCommand.h"
54 #include "RebaseCommand.h"
55 #include "ResolveCommand.h"
56 #include "DropMoveCommand.h"
57 #include "DropCopyAddCommand.h"
58 #include "DropCopyCommand.h"
59 #include "HelpCommand.h"
60 #include "StashCommand.h"
61 #include "SubmoduleCommand.h"
62 #include "ReflogCommand.h"
63 #include "SendMailCommand.h"
64 #include "CatCommand.h"
65 #include "RefBrowseCommand.h"
66 #include "SVNDCommitCommand.h"
67 #include "SVNRebaseCommand.h"
68 #include "SVNFetchCommand.h"
69 #include "SyncCommand.h"
70 #include "RequestPullCommand.h"
71 #include "UpdateCheckCommand.h"
72 #include "PasteCopyCommand.h"
73 #include "PasteMoveCommand.h"
74 #include "SVNIgnoreCommand.h"
75 #include "BisectCommand.h"
76 #include "RepositoryBrowserCommand.h"
77 #include "RevisiongraphCommand.h"
78 #include "ShowCompareCommand.h"
79 #include "DaemonCommand.h"
80 #include "CommitIsOnRefsCommand.h"
81 #include "RTFMCommand.h"
83 #if 0
84 #include "CrashCommand.h"
85 #include "RebuildIconCacheCommand.h"
86 #include "RemoveCommand.h"
87 #include "UnIgnoreCommand.h"
88 #endif
90 typedef enum
92 cmdAbout,
93 cmdAdd,
94 cmdAutoTextTest,
95 cmdBlame,
96 cmdBranch,
97 cmdCat,
98 cmdCleanup,
99 cmdClone,
100 cmdCommit,
101 cmdConflictEditor,
102 cmdCrash,
103 cmdDiff,
104 cmdDropCopy,
105 cmdDropCopyAdd,
106 cmdDropMove,
107 cmdFetch,
108 cmdFormatPatch,
109 cmdExport,
110 cmdHelp,
111 cmdIgnore,
112 cmdImportPatch,
113 cmdLog,
114 cmdMerge,
115 cmdPasteCopy,
116 cmdPasteMove,
117 cmdPrevDiff,
118 cmdPull,
119 cmdPush,
120 cmdRTFM,
121 cmdRebuildIconCache,
122 cmdRemove,
123 cmdRebase,
124 cmdRename,
125 cmdRepoCreate,
126 cmdRepoStatus,
127 cmdResolve,
128 cmdRevert,
129 cmdSendMail,
130 cmdSettings,
131 cmdShowCompare,
132 cmdSwitch,
133 cmdTag,
134 cmdUnIgnore,
135 cmdUpdateCheck,
136 cmdStashSave,
137 cmdStashApply,
138 cmdStashPop,
139 cmdStashList,
140 cmdSubAdd,
141 cmdSubUpdate,
142 cmdSubSync,
143 cmdRefLog,
144 cmdRefBrowse,
145 cmdSVNDCommit,
146 cmdSVNRebase,
147 cmdSVNFetch,
148 cmdSVNIgnore,
149 cmdSync,
150 cmdRequestPull,
151 cmdBisect,
152 cmdRepoBrowser,
153 cmdRevisionGraph,
154 cmdDaemon,
155 cmdPGPFP,
156 cmdCommitIsOnRefs,
157 } TGitCommand;
159 static const struct CommandInfo
161 TGitCommand command;
162 LPCTSTR pCommandName;
163 } commandInfo[] =
165 { cmdAbout, L"about" },
166 { cmdAdd, L"add" },
167 { cmdAutoTextTest, L"autotexttest" },
168 { cmdBlame, L"blame" },
169 { cmdBranch, L"branch" },
170 { cmdCat, L"cat" },
171 { cmdCleanup, L"cleanup" },
172 { cmdClone, L"clone" },
173 { cmdCommit, L"commit" },
174 { cmdConflictEditor, L"conflicteditor" },
175 { cmdCrash, L"crash" },
176 { cmdDiff, L"diff" },
177 { cmdDropCopy, L"dropcopy" },
178 { cmdDropCopyAdd, L"dropcopyadd" },
179 { cmdDropMove, L"dropmove" },
180 { cmdFetch, L"fetch" },
181 { cmdFormatPatch, L"formatpatch" },
182 { cmdExport, L"export" },
183 { cmdHelp, L"help" },
184 { cmdIgnore, L"ignore" },
185 { cmdImportPatch, L"importpatch" },
186 { cmdLog, L"log" },
187 { cmdMerge, L"merge" },
188 { cmdPasteCopy, L"pastecopy" },
189 { cmdPasteMove, L"pastemove" },
190 { cmdPrevDiff, L"prevdiff" },
191 { cmdPull, L"pull" },
192 { cmdPush, L"push" },
193 { cmdRTFM, L"rtfm" },
194 { cmdRebuildIconCache,L"rebuildiconcache" },
195 { cmdRemove, L"remove" },
196 { cmdRebase, L"rebase" },
197 { cmdRename, L"rename" },
198 { cmdRepoCreate, L"repocreate" },
199 { cmdRepoStatus, L"repostatus" },
200 { cmdResolve, L"resolve" },
201 { cmdRevert, L"revert" },
202 { cmdSendMail, L"sendmail" },
203 { cmdSettings, L"settings" },
204 { cmdShowCompare, L"showcompare" },
205 { cmdSwitch, L"switch" },
206 { cmdTag, L"tag" },
207 { cmdUnIgnore, L"unignore" },
208 { cmdUpdateCheck, L"updatecheck" },
209 { cmdStashSave, L"stashsave" },
210 { cmdStashApply, L"stashapply" },
211 { cmdStashPop, L"stashpop" },
212 { cmdStashList, L"stashlist" },
213 { cmdSubAdd, L"subadd" },
214 { cmdSubUpdate, L"subupdate" },
215 { cmdSubSync, L"subsync" },
216 { cmdRefLog, L"reflog" },
217 { cmdRefBrowse, L"refbrowse" },
218 { cmdSVNDCommit, L"svndcommit" },
219 { cmdSVNRebase, L"svnrebase" },
220 { cmdSVNFetch, L"svnfetch" },
221 { cmdSVNIgnore, L"svnignore" },
222 { cmdSync, L"sync" },
223 { cmdRequestPull, L"requestpull" },
224 { cmdBisect, L"bisect" },
225 { cmdRepoBrowser, L"repobrowser" },
226 { cmdRevisionGraph, L"revisiongraph" },
227 { cmdDaemon, L"daemon" },
228 { cmdPGPFP, L"pgpfp" },
229 { cmdCommitIsOnRefs, L"commitisonrefs" },
233 Command * CommandServer::GetCommand(const CString& sCmd)
235 // Look up the command
236 TGitCommand command = cmdAbout; // Something harmless as a default
237 for (int nCommand = 0; nCommand < _countof(commandInfo); ++nCommand)
239 if (sCmd.Compare(commandInfo[nCommand].pCommandName) == 0)
241 // We've found the command
242 command = commandInfo[nCommand].command;
243 // If this fires, you've let the enum get out of sync with the commandInfo array
244 ASSERT((int)command == nCommand);
245 break;
249 // CBrowseRefsDlg dialog
250 switch (command)
252 case cmdAbout:
253 return new AboutCommand;
254 case cmdAutoTextTest:
255 return new AutoTextTestCommand;
256 case cmdCommit:
257 return new CommitCommand;
258 case cmdLog:
259 return new LogCommand;
260 case cmdRepoCreate:
261 return new CreateRepositoryCommand;
262 case cmdClone:
263 return new CloneCommand;
264 case cmdPrevDiff:
265 return new PrevDiffCommand;
266 case cmdDiff:
267 return new DiffCommand;
268 case cmdRename:
269 return new RenameCommand;
270 case cmdRepoStatus:
271 return new RepoStatusCommand;
272 case cmdRemove:
273 return new RemoveCommand;
274 case cmdRevert:
275 return new RevertCommand;
276 case cmdPull:
277 return new PullCommand;
278 case cmdFetch:
279 return new FetchCommand;
280 case cmdPush:
281 return new PushCommand;
282 case cmdBranch:
283 return new BranchCommand;
284 case cmdTag:
285 return new TagCommand;
286 case cmdMerge:
287 return new MergeCommand;
288 case cmdSwitch:
289 return new SwitchCommand;
290 case cmdExport:
291 return new ExportCommand;
292 case cmdAdd:
293 return new AddCommand;
294 case cmdIgnore:
295 return new IgnoreCommand;
296 case cmdFormatPatch:
297 return new FormatPatchCommand;
298 case cmdImportPatch:
299 return new ImportPatchCommand;
300 case cmdBlame:
301 return new BlameCommand;
302 case cmdSettings:
303 return new SettingsCommand;
304 case cmdConflictEditor:
305 return new ConflictEditorCommand;
306 case cmdCleanup:
307 return new CleanupCommand;
308 case cmdRebase:
309 return new RebaseCommand;
310 case cmdResolve:
311 return new ResolveCommand;
312 case cmdDropMove:
313 return new DropMoveCommand;
314 #if 0
315 case cmdDropCopy:
316 return new DropCopyCommand;
317 #endif
318 case cmdDropCopyAdd:
319 return new DropCopyAddCommand;
320 case cmdHelp:
321 return new HelpCommand;
322 case cmdStashSave:
323 return new StashSaveCommand;
324 case cmdStashApply:
325 return new StashApplyCommand;
326 case cmdStashPop:
327 return new StashPopCommand;
328 case cmdSubAdd:
329 return new SubmoduleAddCommand;
330 case cmdSubUpdate:
331 return new SubmoduleUpdateCommand;
332 case cmdRefLog:
333 return new RefLogCommand;
334 case cmdSubSync:
335 return new SubmoduleSyncCommand;
336 case cmdSendMail:
337 return new SendMailCommand;
338 case cmdCat:
339 return new CatCommand;
340 case cmdRefBrowse:
341 return new RefBrowseCommand;
342 case cmdSVNDCommit:
343 return new SVNDCommitCommand;
344 case cmdSVNRebase:
345 return new SVNRebaseCommand;
346 case cmdSVNFetch:
347 return new SVNFetchCommand;
348 case cmdSync:
349 return new SyncCommand;
350 case cmdRequestPull:
351 return new RequestPullCommand;
352 case cmdUpdateCheck:
353 return new UpdateCheckCommand;
354 #if 0
355 case cmdPasteCopy:
356 return new PasteCopyCommand;
357 case cmdPasteMove:
358 return new PasteMoveCommand;
359 #endif
360 case cmdSVNIgnore:
361 return new SVNIgnoreCommand;
362 case cmdBisect:
363 return new BisectCommand;
364 case cmdRepoBrowser:
365 return new RepositoryBrowserCommand;
366 case cmdRevisionGraph:
367 return new RevisionGraphCommand;
368 case cmdShowCompare:
369 return new ShowCompareCommand;
370 case cmdDaemon:
371 return new DaemonCommand;
372 case cmdCommitIsOnRefs:
373 return new CommitIsOnRefsCommand;
374 case cmdRTFM:
375 return new RTFMCommand;
376 #if 0
377 case cmdCrash:
378 return new CrashCommand;
379 case cmdRebuildIconCache:
380 return new RebuildIconCacheCommand;
381 case cmdUnIgnore:
382 return new UnIgnoreCommand;
383 #endif
384 case cmdPGPFP:
386 CMessageBox::Show(hWndExplorer, L"This is the fingerprint of the TortoiseGit Release Signing Key.\nIt can be used to establish a trust path from this release to another one.\n\nTortoiseGit Release Signing Key, 4096-bit RSA:\n74A2 1AE3 01B3 CA5B D807 2F5E F7F1 7B3F 9DD9 539E", L"TortoiseGit", MB_OK);
387 return nullptr;
389 default:
390 CMessageBox::Show(hWndExplorer, L"Command not implemented", L"TortoiseGit", MB_ICONERROR);
391 return new AboutCommand;