mirror of
https://github.com/arcan1s/queued.git
synced 2025-07-22 09:59:55 +00:00
implement support of new commands to clients
This commit is contained in:
@ -149,7 +149,9 @@ void QueuedctlCommon::preprocess(const QStringList &_args,
|
||||
QueuedctlPermissions::parser(_parser);
|
||||
break;
|
||||
case QueuedctlArgument::PluginAdd:
|
||||
case QueuedctlArgument::PluginOptions:
|
||||
case QueuedctlArgument::PluginRemove:
|
||||
case QueuedctlArgument::PluginSpecification:
|
||||
QueuedctlPlugins::parser(_parser);
|
||||
break;
|
||||
case QueuedctlArgument::PluginList:
|
||||
@ -269,10 +271,18 @@ QueuedctlCommon::process(QCommandLineParser &_parser, const QString &_cache,
|
||||
result = QueuedctlPlugins::listPlugins();
|
||||
break;
|
||||
}
|
||||
case QueuedctlArgument::PluginOptions: {
|
||||
result = QueuedctlPlugins::getPluginOptions(args.at(1), token);
|
||||
break;
|
||||
}
|
||||
case QueuedctlArgument::PluginRemove: {
|
||||
result = QueuedctlPlugins::removePlugin(args.at(1), token);
|
||||
break;
|
||||
}
|
||||
case QueuedctlArgument::PluginSpecification: {
|
||||
result = QueuedctlPlugins::getPlugin(args.at(1), token);
|
||||
break;
|
||||
}
|
||||
case QueuedctlArgument::Report: {
|
||||
result = QueuedctlUser::getReport(_parser, token);
|
||||
break;
|
||||
|
@ -32,7 +32,9 @@ enum class QueuedctlArgument {
|
||||
PermissionRemove,
|
||||
PluginAdd,
|
||||
PluginList,
|
||||
PluginOptions,
|
||||
PluginRemove,
|
||||
PluginSpecification,
|
||||
Report,
|
||||
Status,
|
||||
TaskAdd,
|
||||
@ -63,9 +65,13 @@ const QHash<QString, QueuedctlArgumentInfo> QueuedctlArguments = {
|
||||
{QueuedctlArgument::PermissionAdd, "Sets user permission.", 3}},
|
||||
{"perm-remove",
|
||||
{QueuedctlArgument::PermissionRemove, "Removes user permission.", 3}},
|
||||
{"plugin",
|
||||
{QueuedctlArgument::PluginSpecification, "Get plugin description.", 2}},
|
||||
{"plugin-add", {QueuedctlArgument::PluginAdd, "Adds plugin to load.", 2}},
|
||||
{"plugin-list",
|
||||
{QueuedctlArgument::PluginList, "Shows enabled plugins.", 1}},
|
||||
{"plugin-options",
|
||||
{QueuedctlArgument::PluginOptions, "Get plugin options.", 2}},
|
||||
{"plugin-remove",
|
||||
{QueuedctlArgument::PluginRemove, "Removes plugin to load.", 2}},
|
||||
{"report", {QueuedctlArgument::Report, "Shows usage report.", 1}},
|
||||
|
@ -45,9 +45,9 @@ QueuedctlOption::getOption(const QString &_option, const QString &_token)
|
||||
QueuedctlCommon::QueuedctlResult output;
|
||||
auto res = QueuedCoreAdaptor::getOption(_option, _token);
|
||||
res.match(
|
||||
[&output](const QVariant &val) {
|
||||
[&output, &_option](const QVariant &val) {
|
||||
output.status = val.isValid();
|
||||
output.output = val.toString();
|
||||
output.output = QString("%1: %2").arg(_option, val.toString());
|
||||
},
|
||||
[&output](const QueuedError &err) {
|
||||
output.output = err.message().c_str();
|
||||
|
@ -37,6 +37,63 @@ QueuedctlPlugins::addPlugin(const QString &_plugin, const QString &_token)
|
||||
}
|
||||
|
||||
|
||||
QueuedctlCommon::QueuedctlResult
|
||||
QueuedctlPlugins::getPlugin(const QString &_plugin, const QString &_token)
|
||||
{
|
||||
qCDebug(LOG_APP) << "Get plugin" << _plugin;
|
||||
|
||||
auto res = QueuedCoreAdaptor::getPlugin(_plugin, _token);
|
||||
|
||||
QueuedctlCommon::QueuedctlResult output;
|
||||
res.match(
|
||||
[&output](const QueuedPluginSpecification::Plugin &val) {
|
||||
QStringList text;
|
||||
text += QString("Author: %1").arg(val.author);
|
||||
text += QString("Description: %1").arg(val.description);
|
||||
text += QString("Homepage: %1").arg(val.homepage);
|
||||
text += QString("License: %1").arg(val.license);
|
||||
text += QString("Options:");
|
||||
for (auto &opt : val.options) {
|
||||
text += QString(" %1").arg(opt.name);
|
||||
text += QString(" description: %1").arg(opt.description);
|
||||
text += QString(" type: %1").arg(opt.type);
|
||||
text += QString(" default: %1")
|
||||
.arg(opt.defaultValue.toString());
|
||||
}
|
||||
|
||||
output.status = true;
|
||||
output.output = text.join('\n');
|
||||
},
|
||||
[&output](const QueuedError &err) {
|
||||
output.output = err.message().c_str();
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
QueuedctlCommon::QueuedctlResult
|
||||
QueuedctlPlugins::getPluginOptions(const QString &_plugin,
|
||||
const QString &_token)
|
||||
{
|
||||
qCDebug(LOG_APP) << "Get plugin options" << _plugin;
|
||||
|
||||
auto res = QueuedCoreAdaptor::getPluginOptions(_plugin, _token);
|
||||
|
||||
QueuedctlCommon::QueuedctlResult output;
|
||||
res.match(
|
||||
[&output](const QVariantHash &val) {
|
||||
output.status = true;
|
||||
output.output = QueuedctlCommon::hashToString(val);
|
||||
},
|
||||
[&output](const QueuedError &err) {
|
||||
output.output = err.message().c_str();
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
QueuedctlCommon::QueuedctlResult QueuedctlPlugins::listPlugins()
|
||||
{
|
||||
auto res = QueuedCoreAdaptor::getOption(
|
||||
|
@ -26,6 +26,10 @@ namespace QueuedctlPlugins
|
||||
{
|
||||
QueuedctlCommon::QueuedctlResult addPlugin(const QString &_plugin,
|
||||
const QString &_token);
|
||||
QueuedctlCommon::QueuedctlResult getPlugin(const QString &_plugin,
|
||||
const QString &_token);
|
||||
QueuedctlCommon::QueuedctlResult getPluginOptions(const QString &_plugin,
|
||||
const QString &_token);
|
||||
QueuedctlCommon::QueuedctlResult listPlugins();
|
||||
QueuedctlCommon::QueuedctlResult removePlugin(const QString &_plugin,
|
||||
const QString &_token);
|
||||
|
Reference in New Issue
Block a user