aboutsummaryrefslogtreecommitdiff
path: root/src/qmmpui
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmmpui')
-rw-r--r--src/qmmpui/commandlinemanager.cpp21
-rw-r--r--src/qmmpui/commandlinemanager.h2
-rw-r--r--src/qmmpui/commandlineoption.h11
3 files changed, 27 insertions, 7 deletions
diff --git a/src/qmmpui/commandlinemanager.cpp b/src/qmmpui/commandlinemanager.cpp
index 889d8d419..ac2e95aaa 100644
--- a/src/qmmpui/commandlinemanager.cpp
+++ b/src/qmmpui/commandlinemanager.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2016 by Ilya Kotov *
+ * Copyright (C) 2008-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -103,5 +103,22 @@ void CommandLineManager::printUsage()
{
checkOptions();
foreach(CommandLineOption *opt, *m_options)
- cout << qPrintable(opt->helpString());
+ {
+ foreach (QString line, opt->helpString())
+ {
+ QString str = formatHelpString(line);
+ if(!str.isEmpty())
+ cout << qPrintable(str) << endl;
+ }
+ }
+}
+
+QString CommandLineManager::formatHelpString(const QString &line)
+{
+ QStringList list = line.split("||", QString::SkipEmptyParts);
+ if(list.count() == 1)
+ return list.at(0);
+ else if(list.count() >= 2)
+ return list.at(0).leftJustified(25) + list.at(1);
+ return QString();
}
diff --git a/src/qmmpui/commandlinemanager.h b/src/qmmpui/commandlinemanager.h
index 6ced4be5b..81a3bb9e8 100644
--- a/src/qmmpui/commandlinemanager.h
+++ b/src/qmmpui/commandlinemanager.h
@@ -47,6 +47,8 @@ public:
*/
static void printUsage();
+ static QString formatHelpString(const QString &line);
+
private:
static void checkOptions();
static QList<CommandLineOption *> *m_options;
diff --git a/src/qmmpui/commandlineoption.h b/src/qmmpui/commandlineoption.h
index b84a5cbe5..2a1ad71e4 100644
--- a/src/qmmpui/commandlineoption.h
+++ b/src/qmmpui/commandlineoption.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2009 by Ilya Kotov *
+ * Copyright (C) 2008-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -37,15 +37,16 @@ public:
* Returns \b true if \b opt_str string can be processed,
* otherise \b false
*/
- virtual bool identify(const QString& opt_str)const = 0;
+ virtual bool identify(const QString& opt_str) const = 0;
/*!
* Command line option name
*/
- virtual const QString name()const = 0;
+ virtual const QString name() const = 0;
/*!
- * Help string.
+ * A list of specially formatted help strings.
+ * Example: "--help||Display this text and exit".
*/
- virtual const QString helpString()const = 0;
+ virtual const QStringList helpString() const = 0;
/*!
* Parses \b opt_str args(if needed), executes command.
* @param opt_str Command to execute