File indexing completed on 2024-03-24 05:45:15
0001 /*************************************************************************** 0002 * Copyright (C) 2005-2009 by Rajko Albrecht * 0003 * ral@alwins-world.de * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 0019 ***************************************************************************/ 0020 #include "commandline.h" 0021 #include <KHelpClient> 0022 #include <QCommandLineParser> 0023 0024 #include "commandexec.h" 0025 0026 CommandLine::CommandLine(const QCommandLineParser *parser) 0027 : m_parser(parser) 0028 { 0029 } 0030 0031 CommandLine::~CommandLine() 0032 { 0033 } 0034 0035 int CommandLine::exec() 0036 { 0037 if (m_parser->positionalArguments().isEmpty()) { 0038 return -1; 0039 } 0040 if (m_parser->positionalArguments().count() < 2) { 0041 cmd = QLatin1String("help"); 0042 } else { 0043 cmd = m_parser->positionalArguments().at(1); 0044 } 0045 if (cmd == QLatin1String("help")) { 0046 displayHelp(); 0047 return 0; 0048 } 0049 0050 CommandExec exec(nullptr); 0051 0052 return exec.exec(m_parser); 0053 } 0054 0055 void CommandLine::displayHelp() 0056 { 0057 KHelpClient::invokeHelp(QStringLiteral("kdesvn-commandline"), QStringLiteral("kdesvn")); 0058 }