Add Submodule Command
[TortoiseGit.git] / src / TortoiseProc / Commands / Command.cpp
blob5cb7b74127b220f40654bfc2a496d64bbd9439c3
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 #if 0
64 #include "CatCommand.h"
65 #include "CheckoutCommand.h"
69 #include "CopyCommand.h"
70 #include "CrashCommand.h"
71 #include "CreatePatchCommand.h"
73 #include "DelUnversionedCommand.h"
80 #include "ImportCommand.h"
81 #include "LockCommand.h"
84 #include "MergeAllCommand.h"
85 #include "PasteCopyCommand.h"
86 #include "PasteMoveCommand.h"
88 #include "PropertiesCommand.h"
89 #include "RebuildIconCacheCommand.h"
90 #include "RelocateCommand.h"
91 #include "RemoveCommand.h"
93 #include "RepositoryBrowserCommand.h"
96 #include "RevertCommand.h"
97 #include "RevisiongraphCommand.h"
98 #include "RTFMCommand.h"
100 #include "ShowCompareCommand.h"
102 #include "UnIgnoreCommand.h"
103 #include "UnLockCommand.h"
104 #include "UpdateCheckCommand.h"
105 #include "UpdateCommand.h"
106 #include "UrlDiffCommand.h"
107 #endif
108 typedef enum
110 cmdAbout,
111 cmdAdd,
112 cmdBlame,
113 cmdBranch,
114 cmdCat,
115 cmdCheckout,
116 cmdCleanup,
117 cmdClone,
118 cmdCommit,
119 cmdConflictEditor,
120 cmdCopy,
121 cmdCrash,
122 cmdCreatePatch,
123 cmdDelUnversioned,
124 cmdDiff,
125 cmdDropCopy,
126 cmdDropCopyAdd,
127 cmdDropExport,
128 cmdDropMove,
129 cmdFetch,
130 cmdFormatPatch,
131 cmdExport,
132 cmdHelp,
133 cmdIgnore,
134 cmdImport,
135 cmdImportPatch,
136 cmdLock,
137 cmdLog,
138 cmdMerge,
139 cmdMergeAll,
140 cmdPasteCopy,
141 cmdPasteMove,
142 cmdPrevDiff,
143 cmdProperties,
144 cmdPull,
145 cmdPush,
146 cmdRTFM,
147 cmdRebuildIconCache,
148 cmdRelocate,
149 cmdRemove,
150 cmdRebase,
151 cmdRename,
152 cmdRepoBrowser,
153 cmdRepoCreate,
154 cmdRepoStatus,
155 cmdResolve,
156 cmdRevert,
157 cmdRevisionGraph,
158 cmdSettings,
159 cmdShowCompare,
160 cmdSwitch,
161 cmdTag,
162 cmdUnIgnore,
163 cmdUnlock,
164 cmdUpdate,
165 cmdUpdateCheck,
166 cmdUrlDiff,
167 cmdStashSave,
168 cmdStashApply,
169 cmdStashList,
170 cmdSubAdd,
171 cmdSubUpdate,
173 } TGitCommand;
175 static const struct CommandInfo
177 TGitCommand command;
178 LPCTSTR pCommandName;
179 } commandInfo[] =
181 { cmdAbout, _T("about") },
182 { cmdAdd, _T("add") },
183 { cmdBlame, _T("blame") },
184 { cmdBranch, _T("branch") },
185 { cmdCat, _T("cat") },
186 { cmdCheckout, _T("checkout") },
187 { cmdCleanup, _T("cleanup") },
188 { cmdClone, _T("clone") },
189 { cmdCommit, _T("commit") },
190 { cmdConflictEditor, _T("conflicteditor") },
191 { cmdCopy, _T("copy") },
192 { cmdCrash, _T("crash") },
193 { cmdCreatePatch, _T("createpatch") },
194 { cmdDelUnversioned, _T("delunversioned") },
195 { cmdDiff, _T("diff") },
196 { cmdDropCopy, _T("dropcopy") },
197 { cmdDropCopyAdd, _T("dropcopyadd") },
198 { cmdDropExport, _T("dropexport") },
199 { cmdDropMove, _T("dropmove") },
200 { cmdFetch, _T("fetch") },
201 { cmdFormatPatch, _T("formatpatch") },
202 { cmdExport, _T("export") },
203 { cmdHelp, _T("help") },
204 { cmdIgnore, _T("ignore") },
205 { cmdImport, _T("import") },
206 { cmdImportPatch, _T("importpatch") },
207 { cmdLock, _T("lock") },
208 { cmdLog, _T("log") },
209 { cmdMerge, _T("merge") },
210 { cmdMergeAll, _T("mergeall") },
211 { cmdPasteCopy, _T("pastecopy") },
212 { cmdPasteMove, _T("pastemove") },
213 { cmdPrevDiff, _T("prevdiff") },
214 { cmdProperties, _T("properties") },
215 { cmdPull, _T("pull") },
216 { cmdPush, _T("push") },
217 { cmdRTFM, _T("rtfm") },
218 { cmdRebuildIconCache,_T("rebuildiconcache") },
219 { cmdRelocate, _T("relocate") },
220 { cmdRemove, _T("remove") },
221 { cmdRebase, _T("rebase") },
222 { cmdRename, _T("rename") },
223 { cmdRepoBrowser, _T("repobrowser") },
224 { cmdRepoCreate, _T("repocreate") },
225 { cmdRepoStatus, _T("repostatus") },
226 { cmdResolve, _T("resolve") },
227 { cmdRevert, _T("revert") },
228 { cmdRevisionGraph, _T("revisiongraph") },
229 { cmdSettings, _T("settings") },
230 { cmdShowCompare, _T("showcompare") },
231 { cmdSwitch, _T("switch") },
232 { cmdTag, _T("tag") },
233 { cmdUnIgnore, _T("unignore") },
234 { cmdUnlock, _T("unlock") },
235 { cmdUpdate, _T("update") },
236 { cmdUpdateCheck, _T("updatecheck") },
237 { cmdUrlDiff, _T("urldiff") },
238 { cmdStashSave, _T("stashsave") },
239 { cmdStashApply, _T("stashapply") },
240 { cmdStashList, _T("stashlist") },
241 { cmdSubAdd, _T("subadd") },
242 { cmdSubUpdate, _T("subupdate") },
248 Command * CommandServer::GetCommand(const CString& sCmd)
250 // Look up the command
251 TGitCommand command = cmdAbout; // Something harmless as a default
252 for (int nCommand = 0; nCommand < (sizeof(commandInfo)/sizeof(commandInfo[0])); nCommand++)
254 if (sCmd.Compare(commandInfo[nCommand].pCommandName) == 0)
256 // We've found the command
257 command = commandInfo[nCommand].command;
258 // If this fires, you've let the enum get out of sync with the commandInfo array
259 ASSERT((int)command == nCommand);
260 break;
266 switch (command)
268 case cmdAbout:
269 return new AboutCommand;
270 case cmdCommit:
271 return new CommitCommand;
272 case cmdLog:
273 return new LogCommand;
274 case cmdRepoCreate:
275 return new CreateRepositoryCommand;
276 case cmdClone:
277 return new CloneCommand;
278 case cmdPrevDiff:
279 return new PrevDiffCommand;
280 case cmdDiff:
281 return new DiffCommand;
282 case cmdRename:
283 return new RenameCommand;
284 case cmdRepoStatus:
285 return new RepoStatusCommand;
286 case cmdRemove:
287 return new RemoveCommand;
288 case cmdRevert:
289 return new RevertCommand;
290 case cmdPull:
291 return new PullCommand;
292 case cmdFetch:
293 return new FetchCommand;
294 case cmdPush:
295 return new PushCommand;
296 case cmdBranch:
297 return new BranchCommand;
298 case cmdTag:
299 return new TagCommand;
300 case cmdMerge:
301 return new MergeCommand;
302 case cmdSwitch:
303 return new SwitchCommand;
304 case cmdExport:
305 return new ExportCommand;
306 case cmdAdd:
307 return new AddCommand;
308 case cmdIgnore:
309 return new IgnoreCommand;
310 case cmdFormatPatch:
311 return new FormatPatchCommand;
312 case cmdImportPatch:
313 return new ImportPatchCommand;
314 case cmdBlame:
315 return new BlameCommand;
316 case cmdSettings:
317 return new SettingsCommand;
318 case cmdConflictEditor:
319 return new ConflictEditorCommand;
320 case cmdCleanup:
321 return new CleanupCommand;
322 case cmdRebase:
323 return new RebaseCommand;
324 case cmdResolve:
325 return new ResolveCommand;
326 case cmdDropMove:
327 return new DropMoveCommand;
328 // case cmdDropCopy:
329 // return new DropCopyCommand;
330 // case cmdDropCopyAdd:
331 // return new DropCopyAddCommand;
332 // case cmdDropExport:
333 // return new DropExportCommand;
334 case cmdHelp:
335 return new HelpCommand;
336 case cmdStashSave:
337 return new StashSaveCommand;
338 case cmdStashApply:
339 return new StashApplyCommand;
340 case cmdSubAdd:
341 return new SubmoduleAddCommand;
342 case cmdSubUpdate:
343 return new SubmoduleUpdateCommand;
345 #if 0
347 case cmdCat:
348 return new CatCommand;
349 case cmdCheckout:
350 return new CheckoutCommand;
354 case cmdCopy:
355 return new CopyCommand;
356 case cmdCrash:
357 return new CrashCommand;
358 case cmdCreatePatch:
359 return new CreatePatchCommand;
360 case cmdDelUnversioned:
361 return new DelUnversionedCommand;
365 case cmdImport:
366 return new ImportCommand;
367 case cmdLock:
368 return new LockCommand;
369 case cmdMergeAll:
370 return new MergeAllCommand;
371 case cmdPasteCopy:
372 return new PasteCopyCommand;
373 case cmdPasteMove:
374 return new PasteMoveCommand;
375 case cmdPrevDiff:
376 return new PrevDiffCommand;
377 case cmdProperties:
378 return new PropertiesCommand;
379 case cmdRTFM:
380 return new RTFMCommand;
381 case cmdRebuildIconCache:
382 return new RebuildIconCacheCommand;
383 case cmdRelocate:
384 return new RelocateCommand;
385 case cmdRepoBrowser:
386 return new RepositoryBrowserCommand;
387 case cmdRevisionGraph:
388 return new RevisionGraphCommand;
389 case cmdShowCompare:
390 return new ShowCompareCommand;
391 case cmdUnIgnore:
392 return new UnIgnoreCommand;
393 case cmdUnlock:
394 return new UnLockCommand;
395 case cmdUpdate:
396 return new UpdateCommand;
397 case cmdUpdateCheck:
398 return new UpdateCheckCommand;
399 case cmdUrlDiff:
400 return new UrlDiffCommand;
401 #endif
402 default:
403 CMessageBox::Show(hWndExplorer, _T("Have not implemented"), _T("TortoiseGit"), MB_ICONERROR);
404 return new AboutCommand;