mirror of
https://github.com/arcan1s/queued.git
synced 2025-04-24 23:47:19 +00:00
add task helper
This commit is contained in:
parent
9931204837
commit
f59095dbb0
@ -90,7 +90,7 @@ bool sendPluginRemove(const QString &_plugin, const QString &_token);
|
|||||||
* process definitions
|
* process definitions
|
||||||
* @param _token
|
* @param _token
|
||||||
* auth user token
|
* auth user token
|
||||||
* @return task ID or -1 if no task found
|
* @return task ID or {0, -1} if no task added
|
||||||
*/
|
*/
|
||||||
long long
|
long long
|
||||||
sendTaskAdd(const QueuedProcess::QueuedProcessDefinitions &_definitions,
|
sendTaskAdd(const QueuedProcess::QueuedProcessDefinitions &_definitions,
|
||||||
|
@ -119,8 +119,8 @@ public slots:
|
|||||||
qlonglong TaskAdd(const QString &command, const QStringList &arguments,
|
qlonglong TaskAdd(const QString &command, const QStringList &arguments,
|
||||||
const QString &workingDirectory, const qlonglong user,
|
const QString &workingDirectory, const qlonglong user,
|
||||||
const qlonglong cpu, const qlonglong gpu,
|
const qlonglong cpu, const qlonglong gpu,
|
||||||
const QString &memory, const QString &gpumemory,
|
const qlonglong memory, const qlonglong gpumemory,
|
||||||
const QString &storage, const QString &token);
|
const qlonglong storage, const QString &token);
|
||||||
/**
|
/**
|
||||||
* @brief edit task
|
* @brief edit task
|
||||||
* @param id
|
* @param id
|
||||||
@ -157,8 +157,8 @@ public slots:
|
|||||||
const QStringList &arguments, const QString &directory,
|
const QStringList &arguments, const QString &directory,
|
||||||
const uint nice, const uint uid, const uint gid,
|
const uint nice, const uint uid, const uint gid,
|
||||||
const qlonglong user, const qlonglong cpu,
|
const qlonglong user, const qlonglong cpu,
|
||||||
const qlonglong gpu, const QString &memory,
|
const qlonglong gpu, const qlonglong memory,
|
||||||
const QString &gpumemory, const QString &storage,
|
const qlonglong gpumemory, const qlonglong storage,
|
||||||
const QString &token);
|
const QString &token);
|
||||||
/**
|
/**
|
||||||
* @brief force start task
|
* @brief force start task
|
||||||
|
@ -100,32 +100,27 @@ bool QueuedCoreInterface::PluginRemove(const QString &plugin,
|
|||||||
qlonglong QueuedCoreInterface::TaskAdd(
|
qlonglong QueuedCoreInterface::TaskAdd(
|
||||||
const QString &command, const QStringList &arguments,
|
const QString &command, const QStringList &arguments,
|
||||||
const QString &workingDirectory, const qlonglong user, const qlonglong cpu,
|
const QString &workingDirectory, const qlonglong user, const qlonglong cpu,
|
||||||
const qlonglong gpu, const QString &memory, const QString &gpumemory,
|
const qlonglong gpu, const qlonglong memory, const qlonglong gpumemory,
|
||||||
const QString &storage, const QString &token)
|
const qlonglong storage, const QString &token)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_DBUS) << "Add new task with parameters" << command << arguments
|
qCDebug(LOG_DBUS) << "Add new task with parameters" << command << arguments
|
||||||
<< workingDirectory << "from user" << user;
|
<< workingDirectory << "from user" << user;
|
||||||
|
|
||||||
return m_core->addTask(
|
return m_core->addTask(
|
||||||
command, arguments, workingDirectory, user,
|
command, arguments, workingDirectory, user,
|
||||||
QueuedLimits::Limits(cpu, gpu, QueuedLimits::convertMemory(memory),
|
QueuedLimits::Limits(cpu, gpu, memory, gpumemory, storage), token);
|
||||||
QueuedLimits::convertMemory(gpumemory),
|
|
||||||
QueuedLimits::convertMemory(storage)),
|
|
||||||
token);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn TaskEdit
|
* @fn TaskEdit
|
||||||
*/
|
*/
|
||||||
bool QueuedCoreInterface::TaskEdit(const qlonglong id, const QString &command,
|
bool QueuedCoreInterface::TaskEdit(
|
||||||
const QStringList &arguments,
|
const qlonglong id, const QString &command, const QStringList &arguments,
|
||||||
const QString &directory, const uint nice,
|
const QString &directory, const uint nice, const uint uid, const uint gid,
|
||||||
const uint uid, const uint gid,
|
const qlonglong user, const qlonglong cpu, const qlonglong gpu,
|
||||||
const qlonglong user, const qlonglong cpu,
|
const qlonglong memory, const qlonglong gpumemory, const qlonglong storage,
|
||||||
const qlonglong gpu, const QString &memory,
|
const QString &token)
|
||||||
const QString &gpumemory,
|
|
||||||
const QString &storage, const QString &token)
|
|
||||||
{
|
{
|
||||||
qCDebug(LOG_DBUS) << "Edit task" << id << command << arguments << directory
|
qCDebug(LOG_DBUS) << "Edit task" << id << command << arguments << directory
|
||||||
<< nice << uid << gid << cpu << gpu << memory << gpumemory
|
<< nice << uid << gid << cpu << gpu << memory << gpumemory
|
||||||
@ -160,11 +155,11 @@ bool QueuedCoreInterface::TaskEdit(const qlonglong id, const QString &command,
|
|||||||
if (gpu > -1)
|
if (gpu > -1)
|
||||||
limits.gpu = gpu;
|
limits.gpu = gpu;
|
||||||
if (memory > -1)
|
if (memory > -1)
|
||||||
limits.memory = QueuedLimits::convertMemory(memory);
|
limits.memory = memory;
|
||||||
if (gpumemory > -1)
|
if (gpumemory > -1)
|
||||||
limits.gpumemory = QueuedLimits::convertMemory(gpumemory);
|
limits.gpumemory = gpumemory;
|
||||||
if (storage > -1)
|
if (storage > -1)
|
||||||
limits.storage = QueuedLimits::convertMemory(storage);
|
limits.storage = storage;
|
||||||
data[QString("limits")] = limits.toString();
|
data[QString("limits")] = limits.toString();
|
||||||
|
|
||||||
return m_core->editTask(id, data, token);
|
return m_core->editTask(id, data, token);
|
||||||
|
@ -35,6 +35,21 @@ void QueuedctlCommon::checkArgs(const QStringList &_args, const int _count,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString QueuedctlCommon::commandsHelp()
|
||||||
|
{
|
||||||
|
QStringList cmdList = {"Commands:"};
|
||||||
|
|
||||||
|
QStringList commands = QueuedctlArguments.keys();
|
||||||
|
commands.sort();
|
||||||
|
for (auto &cmd : commands)
|
||||||
|
// align like default help message
|
||||||
|
cmdList += QString(" %1%2").arg(cmd, -21).arg(
|
||||||
|
QueuedctlArguments[cmd].description);
|
||||||
|
|
||||||
|
return cmdList.join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void QueuedctlCommon::preprocess(const QStringList &_args,
|
void QueuedctlCommon::preprocess(const QStringList &_args,
|
||||||
QCommandLineParser &_parser)
|
QCommandLineParser &_parser)
|
||||||
{
|
{
|
||||||
@ -42,29 +57,49 @@ void QueuedctlCommon::preprocess(const QStringList &_args,
|
|||||||
|
|
||||||
QString command = _args.isEmpty() ? QString() : _args.first();
|
QString command = _args.isEmpty() ? QString() : _args.first();
|
||||||
// HACK: workaround to show valid help message
|
// HACK: workaround to show valid help message
|
||||||
_parser.addPositionalArgument(command, "Command to execute.");
|
auto id = QueuedctlArguments.contains(command)
|
||||||
|
? QueuedctlArguments[command].id
|
||||||
|
: QueuedctlArgument::Invalid;
|
||||||
|
_parser.addPositionalArgument(id == QueuedctlArgument::Invalid ? "command"
|
||||||
|
: command,
|
||||||
|
"Command to execute.");
|
||||||
|
|
||||||
if (command == "auth")
|
if (command.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (id) {
|
||||||
|
case QueuedctlArgument::Auth:
|
||||||
QueuedctlAuth::parser(_parser);
|
QueuedctlAuth::parser(_parser);
|
||||||
else if (command == "option-get")
|
break;
|
||||||
|
case QueuedctlArgument::OptionGet:
|
||||||
QueuedctlOption::parserGet(_parser);
|
QueuedctlOption::parserGet(_parser);
|
||||||
else if (command == "option-set")
|
break;
|
||||||
|
case QueuedctlArgument::OptionSet:
|
||||||
QueuedctlOption::parserSet(_parser);
|
QueuedctlOption::parserSet(_parser);
|
||||||
else if (command == "task-add")
|
break;
|
||||||
|
case QueuedctlArgument::TaskAdd:
|
||||||
QueuedctlTask::parserAdd(_parser);
|
QueuedctlTask::parserAdd(_parser);
|
||||||
else if (command == "task-get")
|
break;
|
||||||
|
case QueuedctlArgument::TaskGet:
|
||||||
QueuedctlTask::parserGet(_parser);
|
QueuedctlTask::parserGet(_parser);
|
||||||
else if (command == "task-set")
|
break;
|
||||||
|
case QueuedctlArgument::TaskSet:
|
||||||
QueuedctlTask::parserSet(_parser);
|
QueuedctlTask::parserSet(_parser);
|
||||||
else if (command == "user-add") {
|
break;
|
||||||
} else if (command == "user-get") {
|
case QueuedctlArgument::UserAdd:
|
||||||
} else if (command == "user-set") {
|
break;
|
||||||
} else if (!command.isEmpty())
|
case QueuedctlArgument::UserGet:
|
||||||
|
break;
|
||||||
|
case QueuedctlArgument::UserSet:
|
||||||
|
break;
|
||||||
|
case QueuedctlArgument::Invalid:
|
||||||
checkArgs(_args, -1, _parser);
|
checkArgs(_args, -1, _parser);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QueuedctlCommon::print(QueuedctlResult &_result)
|
void QueuedctlCommon::print(const QueuedctlResult &_result)
|
||||||
{
|
{
|
||||||
if (!_result.status)
|
if (!_result.status)
|
||||||
qInfo() << "Subprocess returns error";
|
qInfo() << "Subprocess returns error";
|
||||||
@ -84,19 +119,26 @@ QueuedctlCommon::process(QCommandLineParser &_parser, const QString &_cache,
|
|||||||
QStringList args = _parser.positionalArguments();
|
QStringList args = _parser.positionalArguments();
|
||||||
QString command = args.isEmpty() ? QString() : args.first();
|
QString command = args.isEmpty() ? QString() : args.first();
|
||||||
|
|
||||||
if (command == "auth") {
|
auto id = QueuedctlArguments.contains(command)
|
||||||
checkArgs(args, 1, _parser);
|
? QueuedctlArguments[command].id
|
||||||
|
: QueuedctlArgument::Invalid;
|
||||||
|
checkArgs(args, QueuedctlArguments[command].positionalArgsCount, _parser);
|
||||||
|
|
||||||
|
switch (id) {
|
||||||
|
case QueuedctlArgument::Auth: {
|
||||||
QString token = QueuedctlAuth::auth(_user);
|
QString token = QueuedctlAuth::auth(_user);
|
||||||
result.status = !token.isEmpty();
|
result.status = !token.isEmpty();
|
||||||
if (result.status)
|
if (result.status)
|
||||||
QueuedctlAuth::setToken(token, _cache);
|
QueuedctlAuth::setToken(token, _cache);
|
||||||
} else if (command == "option-get") {
|
break;
|
||||||
checkArgs(args, 2, _parser);
|
}
|
||||||
|
case QueuedctlArgument::OptionGet: {
|
||||||
QVariant value = QueuedctlOption::getOption(args.at(1));
|
QVariant value = QueuedctlOption::getOption(args.at(1));
|
||||||
result.status = value.isValid();
|
result.status = value.isValid();
|
||||||
result.output = value.toString();
|
result.output = value.toString();
|
||||||
} else if (command == "option-set") {
|
break;
|
||||||
checkArgs(args, 3, _parser);
|
}
|
||||||
|
case QueuedctlArgument::OptionSet: {
|
||||||
QString token = QueuedctlAuth::getToken(_cache, _user);
|
QString token = QueuedctlAuth::getToken(_cache, _user);
|
||||||
result.status
|
result.status
|
||||||
= QueuedctlOption::editOption(args.at(1), args.at(2), token);
|
= QueuedctlOption::editOption(args.at(1), args.at(2), token);
|
||||||
@ -106,18 +148,45 @@ QueuedctlCommon::process(QCommandLineParser &_parser, const QString &_cache,
|
|||||||
else
|
else
|
||||||
result.output = QString("Could not set option %1 to %2")
|
result.output = QString("Could not set option %1 to %2")
|
||||||
.arg(args.at(1), args.at(2));
|
.arg(args.at(1), args.at(2));
|
||||||
} else if (command == "task-get") {
|
break;
|
||||||
checkArgs(args, 3, _parser);
|
}
|
||||||
|
case QueuedctlArgument::TaskAdd: {
|
||||||
|
QString token = QueuedctlAuth::getToken(_cache, _user);
|
||||||
|
auto definitions = QueuedctlTask::getDefinitions(_parser, false);
|
||||||
|
long long id = QueuedctlTask::addTask(definitions, token);
|
||||||
|
result.status = (id > 0);
|
||||||
|
if (result.status)
|
||||||
|
result.output = QString("Task %1 added").arg(id);
|
||||||
|
else
|
||||||
|
result.output = QString("Could not add task");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QueuedctlArgument::TaskGet: {
|
||||||
QVariant value
|
QVariant value
|
||||||
= QueuedctlTask::getTask(args.at(1).toLongLong(), args.at(2));
|
= QueuedctlTask::getTask(args.at(1).toLongLong(), args.at(2));
|
||||||
result.status = value.isValid();
|
result.status = value.isValid();
|
||||||
result.output = value.toString();
|
result.output = value.toString();
|
||||||
} else if (command == "task-set") {
|
break;
|
||||||
checkArgs(args, 2, _parser);
|
}
|
||||||
|
case QueuedctlArgument::TaskSet: {
|
||||||
QString token = QueuedctlAuth::getToken(_cache, _user);
|
QString token = QueuedctlAuth::getToken(_cache, _user);
|
||||||
auto definitions = QueuedctlTask::getDefinitions(_parser);
|
auto definitions = QueuedctlTask::getDefinitions(_parser, true);
|
||||||
result.status = QueuedctlTask::setTask(args.at(1).toLongLong(),
|
result.status = QueuedctlTask::setTask(args.at(1).toLongLong(),
|
||||||
definitions, token);
|
definitions, token);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QueuedctlArgument::UserAdd: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QueuedctlArgument::UserGet: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QueuedctlArgument::UserSet: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QueuedctlArgument::Invalid: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -22,14 +22,44 @@
|
|||||||
|
|
||||||
namespace QueuedctlCommon
|
namespace QueuedctlCommon
|
||||||
{
|
{
|
||||||
|
// types and constants
|
||||||
|
enum class QueuedctlArgument {
|
||||||
|
Invalid,
|
||||||
|
Auth,
|
||||||
|
OptionGet,
|
||||||
|
OptionSet,
|
||||||
|
TaskAdd,
|
||||||
|
TaskGet,
|
||||||
|
TaskSet,
|
||||||
|
UserAdd,
|
||||||
|
UserGet,
|
||||||
|
UserSet
|
||||||
|
};
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool status = false;
|
bool status = false;
|
||||||
QString output;
|
QString output;
|
||||||
} QueuedctlResult;
|
} QueuedctlResult;
|
||||||
|
typedef struct {
|
||||||
|
QueuedctlArgument id;
|
||||||
|
QString description;
|
||||||
|
int positionalArgsCount;
|
||||||
|
} QueuedctlArgumentInfo;
|
||||||
|
const QHash<QString, QueuedctlArgumentInfo> QueuedctlArguments
|
||||||
|
= {{"auth", {QueuedctlArgument::Auth, "Gets new auth token.", 1}},
|
||||||
|
{"option-get", {QueuedctlArgument::OptionGet, "Gets option value.", 2}},
|
||||||
|
{"option-set", {QueuedctlArgument::OptionSet, "Sets option value.", 3}},
|
||||||
|
{"task-add", {QueuedctlArgument::TaskAdd, "Adds new task.", 2}},
|
||||||
|
{"task-get", {QueuedctlArgument::TaskGet, "Gets task properties.", 3}},
|
||||||
|
{"task-set", {QueuedctlArgument::TaskSet, "Sets task properties.", 2}},
|
||||||
|
{"user-add", {QueuedctlArgument::UserAdd, "Adds new user."}},
|
||||||
|
{"user-get", {QueuedctlArgument::UserGet, "Gets user properties."}},
|
||||||
|
{"user-set", {QueuedctlArgument::UserSet, "Sets user properties."}}};
|
||||||
|
// methods
|
||||||
void checkArgs(const QStringList &_args, const int _count,
|
void checkArgs(const QStringList &_args, const int _count,
|
||||||
QCommandLineParser &_parser);
|
QCommandLineParser &_parser);
|
||||||
|
QString commandsHelp();
|
||||||
void preprocess(const QStringList &_args, QCommandLineParser &_parser);
|
void preprocess(const QStringList &_args, QCommandLineParser &_parser);
|
||||||
void print(QueuedctlResult &_result);
|
void print(const QueuedctlResult &_result);
|
||||||
QueuedctlResult process(QCommandLineParser &_parser, const QString &_cache,
|
QueuedctlResult process(QCommandLineParser &_parser, const QString &_cache,
|
||||||
const QString &_user);
|
const QString &_user);
|
||||||
};
|
};
|
||||||
|
@ -21,25 +21,33 @@
|
|||||||
#include <queued/Queued.h>
|
#include <queued/Queued.h>
|
||||||
|
|
||||||
|
|
||||||
QueuedProcess::QueuedProcessDefinitions
|
long long QueuedctlTask::addTask(
|
||||||
QueuedctlTask::getDefinitions(const QCommandLineParser &_parser)
|
const QueuedProcess::QueuedProcessDefinitions &_definitions,
|
||||||
|
const QString &_token)
|
||||||
{
|
{
|
||||||
|
qCDebug(LOG_APP) << "Add task" << _definitions.command;
|
||||||
|
|
||||||
|
return QueuedCoreAdaptor::sendTaskAdd(_definitions, _token);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QueuedProcess::QueuedProcessDefinitions
|
||||||
|
QueuedctlTask::getDefinitions(const QCommandLineParser &_parser,
|
||||||
|
const bool _expandAll)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_APP) << "Parse task definitions from parser, expand all"
|
||||||
|
<< _expandAll;
|
||||||
|
|
||||||
QueuedProcess::QueuedProcessDefinitions definitions;
|
QueuedProcess::QueuedProcessDefinitions definitions;
|
||||||
|
|
||||||
definitions.command = _parser.value("program");
|
|
||||||
std::for_each(_parser.values("argument").cbegin(),
|
std::for_each(_parser.values("argument").cbegin(),
|
||||||
_parser.values("argument").cend(),
|
_parser.values("argument").cend(),
|
||||||
[&definitions](const QString &arg) {
|
[&definitions](const QString &arg) {
|
||||||
if (!arg.isEmpty())
|
if (!arg.isEmpty())
|
||||||
definitions.arguments += arg;
|
definitions.arguments += arg;
|
||||||
});
|
});
|
||||||
definitions.endTime
|
|
||||||
= QDateTime::fromString(_parser.value("stop"), Qt::ISODate);
|
|
||||||
definitions.gid = _parser.value("gid").toUInt();
|
|
||||||
definitions.nice = _parser.value("nice").toUInt();
|
definitions.nice = _parser.value("nice").toUInt();
|
||||||
definitions.startTime
|
|
||||||
= QDateTime::fromString(_parser.value("start"), Qt::ISODate);
|
|
||||||
definitions.uid = _parser.value("uid").toUInt();
|
|
||||||
definitions.user = _parser.value("task-user").toLongLong();
|
definitions.user = _parser.value("task-user").toLongLong();
|
||||||
definitions.workingDirectory = _parser.value("directory");
|
definitions.workingDirectory = _parser.value("directory");
|
||||||
// limits now
|
// limits now
|
||||||
@ -51,6 +59,17 @@ QueuedctlTask::getDefinitions(const QCommandLineParser &_parser)
|
|||||||
QueuedLimits::convertMemory(_parser.value("limit-storage")));
|
QueuedLimits::convertMemory(_parser.value("limit-storage")));
|
||||||
definitions.limits = limits.toString();
|
definitions.limits = limits.toString();
|
||||||
|
|
||||||
|
// all options
|
||||||
|
if (_expandAll) {
|
||||||
|
definitions.command = _parser.value("program");
|
||||||
|
definitions.endTime
|
||||||
|
= QDateTime::fromString(_parser.value("stop"), Qt::ISODate);
|
||||||
|
definitions.gid = _parser.value("gid").toUInt();
|
||||||
|
definitions.startTime
|
||||||
|
= QDateTime::fromString(_parser.value("start"), Qt::ISODate);
|
||||||
|
definitions.uid = _parser.value("uid").toUInt();
|
||||||
|
}
|
||||||
|
|
||||||
return definitions;
|
return definitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,8 +92,7 @@ void QueuedctlTask::parserAdd(QCommandLineParser &_parser)
|
|||||||
"Command line argument.", "argument", "");
|
"Command line argument.", "argument", "");
|
||||||
_parser.addOption(argumentOption);
|
_parser.addOption(argumentOption);
|
||||||
// working directory
|
// working directory
|
||||||
QCommandLineOption directoryOption(QStringList() << "d"
|
QCommandLineOption directoryOption("directory",
|
||||||
<< "directory",
|
|
||||||
"Command working directory.",
|
"Command working directory.",
|
||||||
"directory", QDir::currentPath());
|
"directory", QDir::currentPath());
|
||||||
_parser.addOption(directoryOption);
|
_parser.addOption(directoryOption);
|
||||||
@ -131,10 +149,8 @@ void QueuedctlTask::parserSet(QCommandLineParser &_parser)
|
|||||||
"Command line argument.", "argument", "");
|
"Command line argument.", "argument", "");
|
||||||
_parser.addOption(argumentOption);
|
_parser.addOption(argumentOption);
|
||||||
// working directory
|
// working directory
|
||||||
QCommandLineOption directoryOption(QStringList() << "d"
|
QCommandLineOption directoryOption(
|
||||||
<< "directory",
|
"directory", "Command working directory.", "directory", "");
|
||||||
"Command working directory.",
|
|
||||||
"directory", "");
|
|
||||||
_parser.addOption(directoryOption);
|
_parser.addOption(directoryOption);
|
||||||
// user
|
// user
|
||||||
QCommandLineOption userOption("task-user", "Task user.", "task-user", "0");
|
QCommandLineOption userOption("task-user", "Task user.", "task-user", "0");
|
||||||
|
@ -24,8 +24,10 @@
|
|||||||
|
|
||||||
namespace QueuedctlTask
|
namespace QueuedctlTask
|
||||||
{
|
{
|
||||||
|
long long addTask(const QueuedProcess::QueuedProcessDefinitions &_definitions,
|
||||||
|
const QString &_token);
|
||||||
QueuedProcess::QueuedProcessDefinitions
|
QueuedProcess::QueuedProcessDefinitions
|
||||||
getDefinitions(const QCommandLineParser &_parser);
|
getDefinitions(const QCommandLineParser &_parser, const bool _expandAll);
|
||||||
QVariant getTask(const long long _id, const QString &_property);
|
QVariant getTask(const long long _id, const QString &_property);
|
||||||
void parserAdd(QCommandLineParser &_parser);
|
void parserAdd(QCommandLineParser &_parser);
|
||||||
void parserGet(QCommandLineParser &_parser);
|
void parserGet(QCommandLineParser &_parser);
|
||||||
|
@ -42,13 +42,13 @@ int main(int argc, char *argv[])
|
|||||||
// info
|
// info
|
||||||
QCommandLineOption infoOption(QStringList() << "i"
|
QCommandLineOption infoOption(QStringList() << "i"
|
||||||
<< "info",
|
<< "info",
|
||||||
"Show additional info.");
|
"Shows additional info.");
|
||||||
parser.addOption(infoOption);
|
parser.addOption(infoOption);
|
||||||
|
|
||||||
// debug mode
|
// debug mode
|
||||||
QCommandLineOption debugOption(QStringList() << "d"
|
QCommandLineOption debugOption(QStringList() << "d"
|
||||||
<< "debug",
|
<< "debug",
|
||||||
"Print debug information.");
|
"Prints debug information.");
|
||||||
parser.addOption(debugOption);
|
parser.addOption(debugOption);
|
||||||
|
|
||||||
// configuration option
|
// configuration option
|
||||||
@ -63,6 +63,10 @@ int main(int argc, char *argv[])
|
|||||||
"user", ::getlogin());
|
"user", ::getlogin());
|
||||||
parser.addOption(userOption);
|
parser.addOption(userOption);
|
||||||
|
|
||||||
|
// additional help option
|
||||||
|
QCommandLineOption commandsOption("commands", "Lists available commands.");
|
||||||
|
parser.addOption(commandsOption);
|
||||||
|
|
||||||
parser.addPositionalArgument("command", "Command to execute.", "<command>");
|
parser.addPositionalArgument("command", "Command to execute.", "<command>");
|
||||||
|
|
||||||
// pre-parse
|
// pre-parse
|
||||||
@ -80,6 +84,12 @@ int main(int argc, char *argv[])
|
|||||||
QDebug(QtMsgType::QtInfoMsg).noquote() << string;
|
QDebug(QtMsgType::QtInfoMsg).noquote() << string;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (parser.isSet(commandsOption)) {
|
||||||
|
QDebug(QtMsgType::QtInfoMsg).noquote() << parser.helpText();
|
||||||
|
QDebug(QtMsgType::QtInfoMsg).noquote()
|
||||||
|
<< QueuedctlCommon::commandsHelp();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// enable debug
|
// enable debug
|
||||||
if (parser.isSet(debugOption))
|
if (parser.isSet(debugOption))
|
||||||
|
Loading…
Reference in New Issue
Block a user