Added --help option with output

This commit is contained in:
Klaas Freitag 2012-06-15 13:36:38 +02:00
parent c90eb1cca6
commit 9901d3a736
4 changed files with 35 additions and 6 deletions

View file

@ -20,6 +20,8 @@ int main(int argc, char **argv)
Mirall::Application app(argc, argv);
if( ! app.giveHelp() )
return app.exec();
}

View file

@ -13,6 +13,7 @@
*/
#define LOG_TO_CALLBACK // FIXME: This should be in csync.
#include <iostream>
#include "mirall/application.h"
#include "mirall/folder.h"
@ -70,7 +71,8 @@ Application::Application(int &argc, char **argv) :
#endif
_contextMenu(0),
_ocInfo(0),
_updateDetector(0)
_updateDetector(0),
_helpOnly(false)
{
#ifdef OWNCLOUD_CLIENT
@ -81,9 +83,11 @@ Application::Application(int &argc, char **argv) :
setApplicationName( _theme->appName() );
setWindowIcon( _theme->applicationIcon() );
processEvents();
if( arguments().contains("--help")) {
showHelp();
}
setupLogBrowser();
processEvents();
QTranslator *qtTranslator = new QTranslator;
qtTranslator->load("qt_" + QLocale::system().name(),
@ -717,5 +721,23 @@ void Application::computeOverallSyncStatus()
_tray->setToolTip(trayMessage);
}
void Application::showHelp()
{
std::cout << _theme->appName().toLatin1().constData() << " version " <<
_theme->version().toLatin1().constData() << std::endl << std::endl;
std::cout << "File synchronisation desktop utility." << std::endl << std::endl;
std::cout << "Options:" << std::endl;
std::cout << " --logwindow : open a window to show log output." << std::endl;
std::cout << " --logfile <filename> : write log output to file <filename>." << std::endl;
std::cout << " --flushlog : flush the log file after every write." << std::endl;
std::cout << std::endl;
std::cout << "For more information, see http://www.owncloud.org" << std::endl;
_helpOnly = true;
}
bool Application::giveHelp()
{
return _helpOnly;
}
} // namespace Mirall

View file

@ -46,6 +46,9 @@ class Application : public QApplication
public:
explicit Application(int &argc, char **argv);
~Application();
bool giveHelp();
signals:
protected slots:
@ -81,6 +84,8 @@ protected slots:
void slotStartUpdateDetector();
private:
void showHelp();
// configuration file -> folder
QSystemTrayIcon *_tray;
QAction *_actionQuit;
@ -107,6 +112,7 @@ private:
UpdateDetector *_updateDetector;
QMap<Folder*, QString> _overallStatusStrings;
LogBrowser *_logBrowser;
bool _helpOnly;
};
} // namespace Mirall

View file

@ -48,6 +48,7 @@ void UpdateDetector::versionCheck( Theme *theme )
#ifdef Q_OS_MAC
platform = QLatin1String( "macos" );
#endif
qDebug() << "00 client update check to " << url.toString();
QString sysInfo = getSystemInfo();
if( !sysInfo.isEmpty() ) {
@ -56,8 +57,6 @@ void UpdateDetector::versionCheck( Theme *theme )
url.addQueryItem( "version", ver );
url.addQueryItem( "platform", platform );
qDebug() << "00 client update check to " << url.toString();
_accessManager->get( QNetworkRequest( url ));
}