/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. #include "down-worker.h"
  19. #include <iostream>
  20. #include <KAboutData>
  21. #include <KApplication>
  22. #include <KCmdLineArgs>
  23. int main(int argc, char **argv)
  24. {
  25. 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");
  26. about.addAuthor(ki18n("Stefan Majewsky"), ki18n("Maintainer"), "majewsky@gmx.net");
  27. KCmdLineArgs::init(argc, argv, &about, KCmdLineArgs::CmdLineArgNone);
  28. KCmdLineOptions options;
  29. options.add("d");
  30. options.add("drive", ki18n("Argument is a drive name"));
  31. options.add("+point", ki18n("Connection point (or drive if the -d switch is given)"));
  32. KCmdLineArgs::addCmdLineOptions(options);
  33. KApplication app(false);
  34. KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
  35. if (args->count() < 1)
  36. {
  37. Kandas::Console::printError(i18n("Missing argument. Use the --help switch for details."));
  38. return 1;
  39. }
  40. //read command line options
  41. QVariant target(args->arg(0));
  42. if (!args->isSet("drive"))
  43. target.convert(QVariant::Int);
  44. args->clear();
  45. Kandas::Console::DownWorker worker(target);
  46. if (worker.clean())
  47. return app.exec();
  48. else
  49. return 1;
  50. }