Add Cat Command to implement tortoise merge view patch
[TortoiseGit.git] / src / TortoiseProc / Commands / Command.cpp
blobacaa4fed5815f6fb34a6df05187a44793c774395
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "StdAfx.h"
20 #include "Command.h"
22 #include "AboutCommand.h"
23 #include "CommitCommand.h"
24 #include "LogCommand.h"
26 #include "CreateRepositoryCommand.h"
27 #include "CloneCommand.h"
28 #include "PrevDiffCommand.h"
29 #include "DiffCommand.h"
31 #include "RenameCommand.h"
32 #include "RepoStatusCommand.h"
34 #include "RevertCommand.h"
35 #include "RemoveCommand.h"
36 #include "PullCommand.h"
37 #include "FetchCommand.h"
38 #include "PushCommand.h"
39 #include "BranchCommand.h"
40 #include "TagCommand.h"
41 #include "MergeCommand.h"
42 #include "SwitchCommand.h"
43 #include "ExportCommand.h"
44 #include "AddCommand.h"
45 #include "IgnoreCommand.h"
46 #include "FormatPatchCommand.h"
47 #include "ImportPatchCommand.h"
48 #include "BlameCommand.h"
49 #include "SettingsCommand.h"
50 #include "ConflictEditorCommand.h"
51 #include "CleanupCommand.h"
52 #include "RebaseCommand.h"
53 #include "ResolveCommand.h"
54 #include "DropMoveCommand.h"
55 #include "DropCopyAddCommand.h"
56 #include "DropCopyCommand.h"
57 #include "DropExportCommand.h"
58 #include "HelpCommand.h"
59 #include "StashCommand.h"
60 #include "SubmoduleCommand.h"
61 #include "ReflogCommand.h"
62 #include "SendMailCommand.h"
63 #include "CatCommand.h"
65 #if 0
69 #include "CheckoutCommand.h"
73 #include "CopyCommand.h"
74 #include "CrashCommand.h"
75 #include "CreatePatchCommand.h"
77 #include "DelUnversionedCommand.h"
84 #include "ImportCommand.h"
85 #include "LockCommand.h"
88 #include "MergeAllCommand.h"
89 #include "PasteCopyCommand.h"
90 #include "PasteMoveCommand.h"
92 #include "PropertiesCommand.h"
93 #include "RebuildIconCacheCommand.h"
94 #include "RelocateCommand.h"
95 #include "RemoveCommand.h"
97 #include "RepositoryBrowserCommand.h"
100 #include "RevertCommand.h"
101 #include "RevisiongraphCommand.h"
102 #include "RTFMCommand.h"
104 #include "ShowCompareCommand.h"
106 #include "UnIgnoreCommand.h"
107 #include "UnLockCommand.h"
108 #include "UpdateCheckCommand.h"
109 #include "UpdateCommand.h"
110 #include "UrlDiffCommand.h"
111 #endif
112 typedef enum
114 cmdAbout,
115 cmdAdd,
116 cmdBlame,
117 cmdBranch,
118 cmdCat,
119 cmdCheckout,
120 cmdCleanup,
121 cmdClone,
122 cmdCommit,
123 cmdConflictEditor,
124 cmdCopy,
125 cmdCrash,
126 cmdCreatePatch,
127 cmdDelUnversioned,
128 cmdDiff,
129 cmdDropCopy,
130 cmdDropCopyAdd,
131 cmdDropExport,
132 cmdDropMove,
133 cmdFetch,
134 cmdFormatPatch,
135 cmdExport,
136 cmdHelp,
137 cmdIgnore,
138 cmdImport,
139 cmdImportPatch,
140 cmdLock,
141 cmdLog,
142 cmdMerge,
143 cmdMergeAll,
144 cmdPasteCopy,
145 cmdPasteMove,
146 cmdPrevDiff,
147 cmdProperties,
148 cmdPull,
149 cmdPush,
150 cmdRTFM,
151 cmdRebuildIconCache,
152 cmdRelocate,
153 cmdRemove,
154 cmdRebase,
155 cmdRename,
156 cmdRepoBrowser,
157 cmdRepoCreate,
158 cmdRepoStatus,
159 cmdResolve,
160 cmdRevert,
161 cmdRevisionGraph,
162 cmdSendMail,
163 cmdSettings,
164 cmdShowCompare,
165 cmdSwitch,
166 cmdTag,
167 cmdUnIgnore,
168 cmdUnlock,
169 cmdUpdate,
170 cmdUpdateCheck,
171 cmdUrlDiff,
172 cmdStashSave,
173 cmdStashApply,
174 cmdStashList,
175 cmdSubAdd,
176 cmdSubUpdate,
177 cmdSubSync,
178 cmdRefLog,
180 } TGitCommand;
182 static const struct CommandInfo
184 TGitCommand command;
185 LPCTSTR pCommandName;
186 } commandInfo[] =
188 { cmdAbout, _T("about") },
189 { cmdAdd, _T("add") },
190 { cmdBlame, _T("blame") },
191 { cmdBranch, _T("branch") },
192 { cmdCat, _T("cat") },
193 { cmdCheckout, _T("checkout") },
194 { cmdCleanup, _T("cleanup") },
195 { cmdClone, _T("clone") },
196 { cmdCommit, _T("commit") },
197 { cmdConflictEditor, _T("conflicteditor") },
198 { cmdCopy, _T("copy") },
199 { cmdCrash, _T("crash") },
200 { cmdCreatePatch, _T("createpatch") },
201 { cmdDelUnversioned, _T("delunversioned") },
202 { cmdDiff, _T("diff") },
203 { cmdDropCopy, _T("dropcopy") },
204 { cmdDropCopyAdd, _T("dropcopyadd") },
205 { cmdDropExport, _T("dropexport") },
206 { cmdDropMove, _T("dropmove") },
207 { cmdFetch, _T("fetch") },
208 { cmdFormatPatch, _T("formatpatch") },
209 { cmdExport, _T("export") },
210 { cmdHelp, _T("help") },
211 { cmdIgnore, _T("ignore") },
212 { cmdImport, _T("import") },
213 { cmdImportPatch, _T("importpatch") },
214 { cmdLock, _T("lock") },
215 { cmdLog, _T("log") },
216 { cmdMerge, _T("merge") },
217 { cmdMergeAll, _T("mergeall") },
218 { cmdPasteCopy, _T("pastecopy") },
219 { cmdPasteMove, _T("pastemove") },
220 { cmdPrevDiff, _T("prevdiff") },
221 { cmdProperties, _T("properties") },
222 { cmdPull, _T("pull") },
223 { cmdPush, _T("push") },
224 { cmdRTFM, _T("rtfm") },
225 { cmdRebuildIconCache,_T("rebuildiconcache") },
226 { cmdRelocate, _T("relocate") },
227 { cmdRemove, _T("remove") },
228 { cmdRebase, _T("rebase") },
229 { cmdRename, _T("rename") },
230 { cmdRepoBrowser, _T("repobrowser") },
231 { cmdRepoCreate, _T("repocreate") },
232 { cmdRepoStatus, _T("repostatus") },
233 { cmdResolve, _T("resolve") },
234 { cmdRevert, _T("revert") },
235 { cmdRevisionGraph, _T("revisiongraph") },
236 { cmdSendMail, _T("sendmail") },
237 { cmdSettings, _T("settings") },
238 { cmdShowCompare, _T("showcompare") },
239 { cmdSwitch, _T("switch") },
240 { cmdTag, _T("tag") },
241 { cmdUnIgnore, _T("unignore") },
242 { cmdUnlock, _T("unlock") },
243 { cmdUpdate, _T("update") },
244 { cmdUpdateCheck, _T("updatecheck") },
245 { cmdUrlDiff, _T("urldiff") },
246 { cmdStashSave, _T("stashsave") },
247 { cmdStashApply, _T("stashapply") },
248 { cmdStashList, _T("stashlist") },
249 { cmdSubAdd, _T("subadd") },
250 { cmdSubUpdate, _T("subupdate") },
251 { cmdSubSync, _T("subsync") },
252 { cmdRefLog, _T("reflog") }
258 Command * CommandServer::GetCommand(const CString& sCmd)
260 // Look up the command
261 TGitCommand command = cmdAbout; // Something harmless as a default
262 for (int nCommand = 0; nCommand < (sizeof(commandInfo)/sizeof(commandInfo[0])); nCommand++)
264 if (sCmd.Compare(commandInfo[nCommand].pCommandName) == 0)
266 // We've found the command
267 command = commandInfo[nCommand].command;
268 // If this fires, you've let the enum get out of sync with the commandInfo array
269 ASSERT((int)command == nCommand);
270 break;
276 switch (command)
278 case cmdAbout:
279 return new AboutCommand;
280 case cmdCommit:
281 return new CommitCommand;
282 case cmdLog:
283 return new LogCommand;
284 case cmdRepoCreate:
285 return new CreateRepositoryCommand;
286 case cmdClone:
287 return new CloneCommand;
288 case cmdPrevDiff:
289 return new PrevDiffCommand;
290 case cmdDiff:
291 return new DiffCommand;
292 case cmdRename:
293 return new RenameCommand;
294 case cmdRepoStatus:
295 return new RepoStatusCommand;
296 case cmdRemove:
297 return new RemoveCommand;
298 case cmdRevert:
299 return new RevertCommand;
300 case cmdPull:
301 return new PullCommand;
302 case cmdFetch:
303 return new FetchCommand;
304 case cmdPush:
305 return new PushCommand;
306 case cmdBranch:
307 return new BranchCommand;
308 case cmdTag:
309 return new TagCommand;
310 case cmdMerge:
311 return new MergeCommand;
312 case cmdSwitch:
313 return new SwitchCommand;
314 case cmdExport:
315 return new ExportCommand;
316 case cmdAdd:
317 return new AddCommand;
318 case cmdIgnore:
319 return new IgnoreCommand;
320 case cmdFormatPatch:
321 return new FormatPatchCommand;
322 case cmdImportPatch:
323 return new ImportPatchCommand;
324 case cmdBlame:
325 return new BlameCommand;
326 case cmdSettings:
327 return new SettingsCommand;
328 case cmdConflictEditor:
329 return new ConflictEditorCommand;
330 case cmdCleanup:
331 return new CleanupCommand;
332 case cmdRebase:
333 return new RebaseCommand;
334 case cmdResolve:
335 return new ResolveCommand;
336 case cmdDropMove:
337 return new DropMoveCommand;
338 // case cmdDropCopy:
339 // return new DropCopyCommand;
340 // case cmdDropCopyAdd:
341 // return new DropCopyAddCommand;
342 // case cmdDropExport:
343 // return new DropExportCommand;
344 case cmdHelp:
345 return new HelpCommand;
346 case cmdStashSave:
347 return new StashSaveCommand;
348 case cmdStashApply:
349 return new StashApplyCommand;
350 case cmdSubAdd:
351 return new SubmoduleAddCommand;
352 case cmdSubUpdate:
353 return new SubmoduleUpdateCommand;
354 case cmdRefLog:
355 return new RefLogCommand;
356 case cmdSubSync:
357 return new SubmoduleSyncCommand;
358 case cmdSendMail:
359 return new SendMailCommand;
360 case cmdCat:
361 return new CatCommand;
362 #if 0
365 case cmdCheckout:
366 return new CheckoutCommand;
370 case cmdCopy:
371 return new CopyCommand;
372 case cmdCrash:
373 return new CrashCommand;
374 case cmdCreatePatch:
375 return new CreatePatchCommand;
376 case cmdDelUnversioned:
377 return new DelUnversionedCommand;
381 case cmdImport:
382 return new ImportCommand;
383 case cmdLock:
384 return new LockCommand;
385 case cmdMergeAll:
386 return new MergeAllCommand;
387 case cmdPasteCopy:
388 return new PasteCopyCommand;
389 case cmdPasteMove:
390 return new PasteMoveCommand;
391 case cmdPrevDiff:
392 return new PrevDiffCommand;
393 case cmdProperties:
394 return new PropertiesCommand;
395 case cmdRTFM:
396 return new RTFMCommand;
397 case cmdRebuildIconCache:
398 return new RebuildIconCacheCommand;
399 case cmdRelocate:
400 return new RelocateCommand;
401 case cmdRepoBrowser:
402 return new RepositoryBrowserCommand;
403 case cmdRevisionGraph:
404 return new RevisionGraphCommand;
405 case cmdShowCompare:
406 return new ShowCompareCommand;
407 case cmdUnIgnore:
408 return new UnIgnoreCommand;
409 case cmdUnlock:
410 return new UnLockCommand;
411 case cmdUpdate:
412 return new UpdateCommand;
413 case cmdUpdateCheck:
414 return new UpdateCheckCommand;
415 case cmdUrlDiff:
416 return new UrlDiffCommand;
417 #endif
418 default:
419 CMessageBox::Show(hWndExplorer, _T("Have not implemented"), _T("TortoiseGit"), MB_ICONERROR);
420 return new AboutCommand;