1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2009,2011,2013 - TortoiseGit
4 // Copyright (C) 2007 - 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.
21 #include "TortoiseProc.h"
22 #include "CmdLineParser.h"
29 * \ingroup TortoiseProc
30 * Interface for all command line commands TortoiseProc can execute.
36 * Executes the command.
38 virtual bool Execute() = 0;
40 void SetParser(const CCmdLineParser
& p
) {parser
= p
;}
41 void SetPaths(const CTGitPathList
& plist
, const CTGitPath
&path
)
43 orgCmdLinePath
= path
;
44 CString WinPath
=path
.GetWinPath();
45 if(WinPath
.Left(g_Git
.m_CurrentDir
.GetLength())==g_Git
.m_CurrentDir
)
47 if(g_Git
.m_CurrentDir
[g_Git
.m_CurrentDir
.GetLength()-1] == _T('\\'))
49 cmdLinePath
.SetFromWin( WinPath
.Right(WinPath
.GetLength()-g_Git
.m_CurrentDir
.GetLength()));
53 cmdLinePath
.SetFromWin( WinPath
.Right(WinPath
.GetLength()-g_Git
.m_CurrentDir
.GetLength()-1));
57 for (int i
= 0; i
< plist
.GetCount(); ++i
)
59 WinPath
=plist
[i
].GetWinPath();
61 if(WinPath
.Left(g_Git
.m_CurrentDir
.GetLength())==g_Git
.m_CurrentDir
)
63 if(g_Git
.m_CurrentDir
[g_Git
.m_CurrentDir
.GetLength()-1] == _T('\\'))
65 p
.SetFromWin( WinPath
.Right(WinPath
.GetLength()-g_Git
.m_CurrentDir
.GetLength()));
69 p
.SetFromWin( WinPath
.Right(WinPath
.GetLength()-g_Git
.m_CurrentDir
.GetLength()-1));
78 void SetExplorerHwnd(HWND hWnd
) {hwndExplorer
= hWnd
;}
80 CCmdLineParser parser
;
81 CTGitPathList pathList
;
82 CTGitPathList orgPathList
;
83 CTGitPath cmdLinePath
;
84 CTGitPath orgCmdLinePath
;
89 * \ingroup TortoiseProc
90 * Factory for the different commands which TortoiseProc executes from the
97 Command
* GetCommand(const CString
& sCmd
);