PageRenderTime 19ms CodeModel.GetById 11ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/src/kandas-console/down-main.cpp

http://kandas.googlecode.com/
C++ | 57 lines | 32 code | 7 blank | 18 comment | 3 complexity | f4b5f45ca35de98a864c1ea57415ad68 MD5 | raw file
 1/***************************************************************************
 2 *   Copyright 2008-2009 Stefan Majewsky <majewsky@gmx.net>
 3 *
 4 *   This program is free software; you can redistribute it and/or
 5 *   modify it under the terms of the GNU General Public
 6 *   License as published by the Free Software Foundation; either
 7 *   version 2 of the License, or (at your option) any later version.
 8 *
 9 *   This program is distributed in the hope that it will be useful,
10 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 *   GNU General Public License for more details.
13 *
14 *   You should have received a copy of the GNU General Public License
15 *   along with this program; if not, write to the Free Software
16 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 ***************************************************************************/
18
19#include "down-worker.h"
20
21#include <iostream>
22#include <KAboutData>
23#include <KApplication>
24#include <KCmdLineArgs>
25
26int main(int argc, char **argv)
27{
28    KAboutData about("kandas-down", "kandas", ki18n("KaNDAS-down"), Kandas::Console::VersionRaw, ki18n(Kandas::Console::Description), KAboutData::License_GPL, ki18n("Copyright 2008-2009 Stefan Majewsky"), KLocalizedString(), "http://code.google.com/p/kandas/", "majewsky@gmx.net");
29    about.addAuthor(ki18n("Stefan Majewsky"), ki18n("Maintainer"), "majewsky@gmx.net");
30    KCmdLineArgs::init(argc, argv, &about, KCmdLineArgs::CmdLineArgNone);
31
32    KCmdLineOptions options;
33    options.add("d");
34    options.add("drive", ki18n("Argument is a drive name"));
35    options.add("+point", ki18n("Connection point (or drive if the -d switch is given)"));
36    KCmdLineArgs::addCmdLineOptions(options);
37
38    KApplication app(false);
39
40    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
41    if (args->count() < 1)
42    {
43        Kandas::Console::printError(i18n("Missing argument. Use the --help switch for details."));
44        return 1;
45    }
46    //read command line options
47    QVariant target(args->arg(0));
48    if (!args->isSet("drive"))
49        target.convert(QVariant::Int);
50    args->clear();
51
52    Kandas::Console::DownWorker worker(target);
53    if (worker.clean())
54        return app.exec();
55    else
56        return 1;
57}