From c82c80d031d50e445bda7c02adbd3e97a635cde6 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Thu, 2 Aug 2018 14:08:35 +0200 Subject: Put "syntax" at the bottom --- sinksh/syntax_modules/sink_clear.cpp | 28 ++++++------ sinksh/syntax_modules/sink_count.cpp | 30 ++++++------- sinksh/syntax_modules/sink_create.cpp | 73 +++++++++++++++----------------- sinksh/syntax_modules/sink_drop.cpp | 24 +++++------ sinksh/syntax_modules/sink_inspect.cpp | 50 +++++++++++----------- sinksh/syntax_modules/sink_list.cpp | 44 +++++++++---------- sinksh/syntax_modules/sink_livequery.cpp | 38 ++++++++--------- sinksh/syntax_modules/sink_modify.cpp | 49 +++++++++++---------- sinksh/syntax_modules/sink_remove.cpp | 55 ++++++++++++------------ sinksh/syntax_modules/sink_selftest.cpp | 18 ++++---- sinksh/syntax_modules/sink_stat.cpp | 38 ++++++++--------- sinksh/syntax_modules/sink_sync.cpp | 32 +++++++------- sinksh/syntax_modules/sink_trace.cpp | 40 ++++++++--------- sinksh/syntax_modules/sink_upgrade.cpp | 16 +++---- 14 files changed, 258 insertions(+), 277 deletions(-) diff --git a/sinksh/syntax_modules/sink_clear.cpp b/sinksh/syntax_modules/sink_clear.cpp index 536e9df..ca38943 100644 --- a/sinksh/syntax_modules/sink_clear.cpp +++ b/sinksh/syntax_modules/sink_clear.cpp @@ -35,20 +35,7 @@ namespace SinkClear { -bool clear(const QStringList &args, State &state); - -Syntax::List syntax() -{ - Syntax clear("clear", QObject::tr("Clears the local cache of one or more resources (be careful!)"), &SinkClear::clear, Syntax::NotInteractive); - - clear.addPositionalArgument({.name = "resource", .help = "The resource to clear"}); - - clear.completer = &SinkshUtils::resourceCompleter; - - return Syntax::List() << clear; -} - -REGISTER_SYNTAX(SinkClear) +Syntax::List syntax(); bool clear(const QStringList &args, State &state) { @@ -65,4 +52,17 @@ bool clear(const QStringList &args, State &state) return true; } +Syntax::List syntax() +{ + Syntax clear("clear", QObject::tr("Clears the local cache of one or more resources (be careful!)"), &SinkClear::clear, Syntax::NotInteractive); + + clear.addPositionalArgument({.name = "resource", .help = "The resource to clear"}); + + clear.completer = &SinkshUtils::resourceCompleter; + + return Syntax::List() << clear; +} + +REGISTER_SYNTAX(SinkClear) + } diff --git a/sinksh/syntax_modules/sink_count.cpp b/sinksh/syntax_modules/sink_count.cpp index aaa9c33..1edf1c2 100644 --- a/sinksh/syntax_modules/sink_count.cpp +++ b/sinksh/syntax_modules/sink_count.cpp @@ -37,21 +37,7 @@ namespace SinkCount { -bool count(const QStringList &args, State &state); - -Syntax::List syntax() -{ - Syntax count("count", QObject::tr("Returns the number of items of a given type in a resource"), &SinkCount::count, Syntax::EventDriven); - - count.addPositionalArgument({.name = "type", .help = "The entity type to count"}); - count.addPositionalArgument({.name = "resource", .help = "A resource id where to count", .required = false}); - - count.completer = &SinkshUtils::typeCompleter; - - return Syntax::List() << count; -} - -REGISTER_SYNTAX(SinkCount) +Syntax::List syntax(); bool count(const QStringList &args, State &state) { @@ -77,4 +63,18 @@ bool count(const QStringList &args, State &state) return true; } +Syntax::List syntax() +{ + Syntax count("count", QObject::tr("Returns the number of items of a given type in a resource"), &SinkCount::count, Syntax::EventDriven); + + count.addPositionalArgument({.name = "type", .help = "The entity type to count"}); + count.addPositionalArgument({.name = "resource", .help = "A resource id where to count", .required = false}); + + count.completer = &SinkshUtils::typeCompleter; + + return Syntax::List() << count; +} + +REGISTER_SYNTAX(SinkCount) + } diff --git a/sinksh/syntax_modules/sink_create.cpp b/sinksh/syntax_modules/sink_create.cpp index b7025cc..b1631cd 100644 --- a/sinksh/syntax_modules/sink_create.cpp +++ b/sinksh/syntax_modules/sink_create.cpp @@ -40,44 +40,7 @@ using namespace Sink; namespace SinkCreate { -bool create(const QStringList &allArgs, State &state); -bool resource(const QStringList &args, State &state); -bool account(const QStringList &args, State &state); -bool identity(const QStringList &args, State &state); - -Syntax::List syntax() -{ - Syntax::List syntax; - - Syntax create("create", QObject::tr("Create items in a resource"), &SinkCreate::create); - create.addPositionalArgument({ .name = "type", .help = "The type of entity to create (mail, event, etc.)" }); - create.addPositionalArgument({ .name = "resourceId", .help = "The ID of the resource that will contain the new entity" }); - create.addPositionalArgument( - { .name = "key value", .help = "Content of the entity", .required = false, .variadic = true }); - - Syntax resource("resource", QObject::tr("Creates a new resource"), &SinkCreate::resource); - resource.addPositionalArgument({ .name = "type", .help = "The type of resource to create" }); - resource.addPositionalArgument( - { .name = "key value", .help = "Content of the resource", .required = false, .variadic = true }); - - Syntax account("account", QObject::tr("Creates a new account"), &SinkCreate::account); - account.addPositionalArgument({ .name = "type", .help = "The type of account to create" }); - account.addPositionalArgument( - { .name = "key value", .help = "Content of the account", .required = false, .variadic = true }); - - Syntax identity("identity", QObject::tr("Creates a new identity"), &SinkCreate::identity); - identity.addPositionalArgument( - { .name = "key value", .help = "Content of the identity", .required = false, .variadic = true }); - - create.children << resource; - create.children << account; - create.children << identity; - - syntax << create; - return syntax; -} - -REGISTER_SYNTAX(SinkCreate) +Syntax::List syntax(); bool create(const QStringList &allArgs, State &state) { @@ -207,4 +170,38 @@ bool identity(const QStringList &args, State &state) return true; } +Syntax::List syntax() +{ + Syntax::List syntax; + + Syntax create("create", QObject::tr("Create items in a resource"), &SinkCreate::create); + create.addPositionalArgument({ .name = "type", .help = "The type of entity to create (mail, event, etc.)" }); + create.addPositionalArgument({ .name = "resourceId", .help = "The ID of the resource that will contain the new entity" }); + create.addPositionalArgument( + { .name = "key value", .help = "Content of the entity", .required = false, .variadic = true }); + + Syntax resource("resource", QObject::tr("Creates a new resource"), &SinkCreate::resource); + resource.addPositionalArgument({ .name = "type", .help = "The type of resource to create" }); + resource.addPositionalArgument( + { .name = "key value", .help = "Content of the resource", .required = false, .variadic = true }); + + Syntax account("account", QObject::tr("Creates a new account"), &SinkCreate::account); + account.addPositionalArgument({ .name = "type", .help = "The type of account to create" }); + account.addPositionalArgument( + { .name = "key value", .help = "Content of the account", .required = false, .variadic = true }); + + Syntax identity("identity", QObject::tr("Creates a new identity"), &SinkCreate::identity); + identity.addPositionalArgument( + { .name = "key value", .help = "Content of the identity", .required = false, .variadic = true }); + + create.children << resource; + create.children << account; + create.children << identity; + + syntax << create; + return syntax; +} + +REGISTER_SYNTAX(SinkCreate) + } diff --git a/sinksh/syntax_modules/sink_drop.cpp b/sinksh/syntax_modules/sink_drop.cpp index 2353ed1..eaa3041 100644 --- a/sinksh/syntax_modules/sink_drop.cpp +++ b/sinksh/syntax_modules/sink_drop.cpp @@ -35,18 +35,7 @@ namespace SinkDrop { -bool drop(const QStringList &args, State &state); - -Syntax::List syntax() -{ - Syntax drop("drop", QObject::tr("Drop all caches of a resource."), &SinkDrop::drop, Syntax::NotInteractive); - drop.addPositionalArgument({.name = "resource", .help = "Id(s) of the resource(s) to drop", .required = true, .variadic = true}); - - drop.completer = &SinkshUtils::resourceOrTypeCompleter; - return Syntax::List() << drop; -} - -REGISTER_SYNTAX(SinkDrop) +Syntax::List syntax(); bool drop(const QStringList &args, State &state) { @@ -70,4 +59,15 @@ bool drop(const QStringList &args, State &state) return false; } +Syntax::List syntax() +{ + Syntax drop("drop", QObject::tr("Drop all caches of a resource."), &SinkDrop::drop, Syntax::NotInteractive); + drop.addPositionalArgument({.name = "resource", .help = "Id(s) of the resource(s) to drop", .required = true, .variadic = true}); + + drop.completer = &SinkshUtils::resourceOrTypeCompleter; + return Syntax::List() << drop; +} + +REGISTER_SYNTAX(SinkDrop) + } diff --git a/sinksh/syntax_modules/sink_inspect.cpp b/sinksh/syntax_modules/sink_inspect.cpp index d952a9b..355efa3 100644 --- a/sinksh/syntax_modules/sink_inspect.cpp +++ b/sinksh/syntax_modules/sink_inspect.cpp @@ -55,31 +55,7 @@ QString parse(const QByteArray &bytes) } } -bool inspect(const QStringList &args, State &state); - -Syntax::List syntax() -{ - Syntax state("inspect", QObject::tr("Inspect database for the resource requested"), - &SinkInspect::inspect, Syntax::NotInteractive); - - state.addParameter("resource", - { .name = "resource", .help = "Which resource to inspect", .required = true }); - state.addParameter("db", - { .name = "database", .help = "Which database to inspect"}); - state.addParameter("filter", - { .name = "id", .help = "A specific id to filter the results by (currently not working)"}); - state.addFlag("showinternal", "Show internal fields only"); - state.addParameter("validaterids", - { .name = "type", .help = "Validate remote Ids of the given type"}); - state.addParameter("fulltext", - { .name = "id", .help = "If 'id' is not given, count the number of fulltext documents. Else, print the terms of the document with the given id"}); - - state.completer = &SinkshUtils::resourceCompleter; - - return Syntax::List() << state; -} - -REGISTER_SYNTAX(SinkInspect) +Syntax::List syntax(); bool inspect(const QStringList &args, State &state) { @@ -262,4 +238,28 @@ bool inspect(const QStringList &args, State &state) return false; } +Syntax::List syntax() +{ + Syntax state("inspect", QObject::tr("Inspect database for the resource requested"), + &SinkInspect::inspect, Syntax::NotInteractive); + + state.addParameter("resource", + { .name = "resource", .help = "Which resource to inspect", .required = true }); + state.addParameter("db", + { .name = "database", .help = "Which database to inspect"}); + state.addParameter("filter", + { .name = "id", .help = "A specific id to filter the results by (currently not working)"}); + state.addFlag("showinternal", "Show internal fields only"); + state.addParameter("validaterids", + { .name = "type", .help = "Validate remote Ids of the given type"}); + state.addParameter("fulltext", + { .name = "id", .help = "If 'id' is not given, count the number of fulltext documents. Else, print the terms of the document with the given id"}); + + state.completer = &SinkshUtils::resourceCompleter; + + return Syntax::List() << state; +} + +REGISTER_SYNTAX(SinkInspect) + } diff --git a/sinksh/syntax_modules/sink_list.cpp b/sinksh/syntax_modules/sink_list.cpp index c091cd4..903dc2a 100644 --- a/sinksh/syntax_modules/sink_list.cpp +++ b/sinksh/syntax_modules/sink_list.cpp @@ -39,28 +39,7 @@ namespace SinkList { -bool list(const QStringList &args_, State &state); - -Syntax::List syntax() -{ - Syntax list("list", QObject::tr("List all resources, or the contents of one or more resources."), &SinkList::list, Syntax::NotInteractive); - - list.addPositionalArgument({.name = "type", .help = "The type of content to list (resource, identity, account, mail, etc.)"}); - list.addParameter("resource", { .name = "resource", .help = "List only the content of the given resource" }); - list.addFlag("compact", "Use a compact view (reduces the size of IDs)"); - list.addParameter("filter", { .name = "property=$value", .help = "Filter the results" }); - list.addParameter("id", { .name = "id", .help = "List only the content with the given ID" }); - list.addFlag("showall", "Show all properties"); - list.addParameter("show", { .name = "property", .help = "Only show the given property" }); - list.addParameter("reduce", { .name = "property:$selectorProperty", .help = "Combine the result with the same $property, sorted by $selectorProperty" }); - list.addParameter("sort", { .name = "property", .help = "Sort the results according to the given property" }); - list.addParameter("limit", { .name = "count", .help = "Limit the results" }); - - list.completer = &SinkshUtils::resourceOrTypeCompleter; - return Syntax::List() << list; -} - -REGISTER_SYNTAX(SinkList) +Syntax::List syntax(); static QByteArray compressId(bool compress, const QByteArray &id) { @@ -216,4 +195,25 @@ bool list(const QStringList &args_, State &state) return true; } +Syntax::List syntax() +{ + Syntax list("list", QObject::tr("List all resources, or the contents of one or more resources."), &SinkList::list, Syntax::NotInteractive); + + list.addPositionalArgument({.name = "type", .help = "The type of content to list (resource, identity, account, mail, etc.)"}); + list.addParameter("resource", { .name = "resource", .help = "List only the content of the given resource" }); + list.addFlag("compact", "Use a compact view (reduces the size of IDs)"); + list.addParameter("filter", { .name = "property=$value", .help = "Filter the results" }); + list.addParameter("id", { .name = "id", .help = "List only the content with the given ID" }); + list.addFlag("showall", "Show all properties"); + list.addParameter("show", { .name = "property", .help = "Only show the given property" }); + list.addParameter("reduce", { .name = "property:$selectorProperty", .help = "Combine the result with the same $property, sorted by $selectorProperty" }); + list.addParameter("sort", { .name = "property", .help = "Sort the results according to the given property" }); + list.addParameter("limit", { .name = "count", .help = "Limit the results" }); + + list.completer = &SinkshUtils::resourceOrTypeCompleter; + return Syntax::List() << list; +} + +REGISTER_SYNTAX(SinkList) + } diff --git a/sinksh/syntax_modules/sink_livequery.cpp b/sinksh/syntax_modules/sink_livequery.cpp index 0acaaeb..2d8d5d0 100644 --- a/sinksh/syntax_modules/sink_livequery.cpp +++ b/sinksh/syntax_modules/sink_livequery.cpp @@ -38,25 +38,7 @@ namespace SinkLiveQuery { -bool livequery(const QStringList &args_, State &state); - -Syntax::List syntax() -{ - Syntax list("livequery", QObject::tr("Run a livequery."), &SinkLiveQuery::livequery, Syntax::EventDriven); - - list.addPositionalArgument({ .name = "type", .help = "The type to run the livequery on" }); - list.addParameter("resource", { .name = "resource", .help = "Filter the livequery to the given resource" }); - list.addFlag("compact", "Use a compact view (reduces the size of IDs)"); - list.addParameter("filter", { .name = "property=$value", .help = "Filter the results" }); - list.addParameter("id", { .name = "id", .help = "List only the content with the given ID" }); - list.addFlag("showall", "Show all properties"); - list.addParameter("show", { .name = "property", .help = "Only show the given property" }); - - list.completer = &SinkshUtils::resourceOrTypeCompleter; - return Syntax::List() << list; -} - -REGISTER_SYNTAX(SinkLiveQuery) +Syntax::List syntax(); bool livequery(const QStringList &args_, State &state) { @@ -141,4 +123,22 @@ bool livequery(const QStringList &args_, State &state) return false; } +Syntax::List syntax() +{ + Syntax list("livequery", QObject::tr("Run a livequery."), &SinkLiveQuery::livequery, Syntax::EventDriven); + + list.addPositionalArgument({ .name = "type", .help = "The type to run the livequery on" }); + list.addParameter("resource", { .name = "resource", .help = "Filter the livequery to the given resource" }); + list.addFlag("compact", "Use a compact view (reduces the size of IDs)"); + list.addParameter("filter", { .name = "property=$value", .help = "Filter the results" }); + list.addParameter("id", { .name = "id", .help = "List only the content with the given ID" }); + list.addFlag("showall", "Show all properties"); + list.addParameter("show", { .name = "property", .help = "Only show the given property" }); + + list.completer = &SinkshUtils::resourceOrTypeCompleter; + return Syntax::List() << list; +} + +REGISTER_SYNTAX(SinkLiveQuery) + } diff --git a/sinksh/syntax_modules/sink_modify.cpp b/sinksh/syntax_modules/sink_modify.cpp index cd29d56..6cda5ab 100644 --- a/sinksh/syntax_modules/sink_modify.cpp +++ b/sinksh/syntax_modules/sink_modify.cpp @@ -38,31 +38,7 @@ namespace SinkModify { -bool modify(const QStringList &args, State &state); -bool resource(const QStringList &args, State &state); - -Syntax::List syntax() -{ - Syntax modify("modify", QObject::tr("Modify items in a resource"), &SinkModify::modify); - modify.addPositionalArgument({ .name = "type", .help = "The type of entity to modify (mail, event, etc.)" }); - modify.addPositionalArgument({ .name = "resourceId", .help = "The ID of the resource containing the entity" }); - modify.addPositionalArgument({ .name = "objectId", .help = "The ID of the entity" }); - modify.addPositionalArgument( - { .name = "key value", .help = "Attributes and values to modify", .required = false, .variadic = true }); - - Syntax resource("resource", QObject::tr("Modify a resource"), &SinkModify::resource);//, Syntax::EventDriven); - - resource.addPositionalArgument({ .name = "id", .help = "The ID of the resource" }); - resource.addPositionalArgument( - { .name = "key value", .help = "Attributes and values to modify", .required = false, .variadic = true }); - - resource.completer = &SinkshUtils::resourceOrTypeCompleter; - modify.children << resource; - - return Syntax::List() << modify; -} - -REGISTER_SYNTAX(SinkModify) +Syntax::List syntax(); bool modify(const QStringList &args, State &state) { @@ -122,4 +98,27 @@ bool resource(const QStringList &args, State &state) return true; } +Syntax::List syntax() +{ + Syntax modify("modify", QObject::tr("Modify items in a resource"), &SinkModify::modify); + modify.addPositionalArgument({ .name = "type", .help = "The type of entity to modify (mail, event, etc.)" }); + modify.addPositionalArgument({ .name = "resourceId", .help = "The ID of the resource containing the entity" }); + modify.addPositionalArgument({ .name = "objectId", .help = "The ID of the entity" }); + modify.addPositionalArgument( + { .name = "key value", .help = "Attributes and values to modify", .required = false, .variadic = true }); + + Syntax resource("resource", QObject::tr("Modify a resource"), &SinkModify::resource);//, Syntax::EventDriven); + + resource.addPositionalArgument({ .name = "id", .help = "The ID of the resource" }); + resource.addPositionalArgument( + { .name = "key value", .help = "Attributes and values to modify", .required = false, .variadic = true }); + + resource.completer = &SinkshUtils::resourceOrTypeCompleter; + modify.children << resource; + + return Syntax::List() << modify; +} + +REGISTER_SYNTAX(SinkModify) + } diff --git a/sinksh/syntax_modules/sink_remove.cpp b/sinksh/syntax_modules/sink_remove.cpp index f948290..999a889 100644 --- a/sinksh/syntax_modules/sink_remove.cpp +++ b/sinksh/syntax_modules/sink_remove.cpp @@ -37,35 +37,7 @@ namespace SinkRemove { -bool remove(const QStringList &args, State &state); -bool resource(const QStringList &args, State &state); -bool account(const QStringList &args, State &state); -bool identity(const QStringList &args, State &state); - -Syntax::List syntax() -{ - Syntax remove("remove", QObject::tr("Remove items in a resource"), &SinkRemove::remove); - - remove.addPositionalArgument({ .name = "type", .help = "The type of entity to remove (mail, event, etc.)" }); - remove.addPositionalArgument({ .name = "resourceId", .help = "The ID of the resource containing the entity" }); - remove.addPositionalArgument({ .name = "objectId", .help = "The ID of the entity to remove" }); - - Syntax resource("resource", QObject::tr("Removes a resource"), &SinkRemove::resource, Syntax::NotInteractive); - resource.addPositionalArgument({ .name = "id", .help = "The ID of the resource to remove" }); - resource.completer = &SinkshUtils::resourceCompleter; - - Syntax account("account", QObject::tr("Removes a account"), &SinkRemove::account, Syntax::NotInteractive); - account.addPositionalArgument({ .name = "id", .help = "The ID of the account to remove" }); - - Syntax identity("identity", QObject::tr("Removes an identity"), &SinkRemove::identity, Syntax::NotInteractive); - identity.addPositionalArgument({ .name = "id", .help = "The ID of the account to remove" }); - - remove.children << resource << account << identity; - - return Syntax::List() << remove; -} - -REGISTER_SYNTAX(SinkRemove) +Syntax::List syntax(); bool remove(const QStringList &args, State &state) { @@ -157,4 +129,29 @@ bool identity(const QStringList &args, State &state) return true; } +Syntax::List syntax() +{ + Syntax remove("remove", QObject::tr("Remove items in a resource"), &SinkRemove::remove); + + remove.addPositionalArgument({ .name = "type", .help = "The type of entity to remove (mail, event, etc.)" }); + remove.addPositionalArgument({ .name = "resourceId", .help = "The ID of the resource containing the entity" }); + remove.addPositionalArgument({ .name = "objectId", .help = "The ID of the entity to remove" }); + + Syntax resource("resource", QObject::tr("Removes a resource"), &SinkRemove::resource, Syntax::NotInteractive); + resource.addPositionalArgument({ .name = "id", .help = "The ID of the resource to remove" }); + resource.completer = &SinkshUtils::resourceCompleter; + + Syntax account("account", QObject::tr("Removes a account"), &SinkRemove::account, Syntax::NotInteractive); + account.addPositionalArgument({ .name = "id", .help = "The ID of the account to remove" }); + + Syntax identity("identity", QObject::tr("Removes an identity"), &SinkRemove::identity, Syntax::NotInteractive); + identity.addPositionalArgument({ .name = "id", .help = "The ID of the account to remove" }); + + remove.children << resource << account << identity; + + return Syntax::List() << remove; +} + +REGISTER_SYNTAX(SinkRemove) + } diff --git a/sinksh/syntax_modules/sink_selftest.cpp b/sinksh/syntax_modules/sink_selftest.cpp index 132b952..a1c7dcb 100644 --- a/sinksh/syntax_modules/sink_selftest.cpp +++ b/sinksh/syntax_modules/sink_selftest.cpp @@ -41,16 +41,6 @@ namespace SinkSelfTest { -bool selfTest(const QStringList &args_, State &state); - -Syntax::List syntax() -{ - Syntax syntax("selftest", QObject::tr("A selftest module."), &SinkSelfTest::selfTest, Syntax::EventDriven); - return Syntax::List() << syntax; -} - -REGISTER_SYNTAX(SinkSelfTest) - bool selfTest(const QStringList &args_, State &state) { using namespace Sink::ApplicationDomain; @@ -164,4 +154,12 @@ bool selfTest(const QStringList &args_, State &state) return false; } +Syntax::List syntax() +{ + Syntax syntax("selftest", QObject::tr("A selftest module."), &SinkSelfTest::selfTest, Syntax::EventDriven); + return Syntax::List() << syntax; +} + +REGISTER_SYNTAX(SinkSelfTest) + } diff --git a/sinksh/syntax_modules/sink_stat.cpp b/sinksh/syntax_modules/sink_stat.cpp index 235558f..a936af2 100644 --- a/sinksh/syntax_modules/sink_stat.cpp +++ b/sinksh/syntax_modules/sink_stat.cpp @@ -36,26 +36,6 @@ namespace SinkStat { -bool stat(const QStringList &args, State &state); - -Syntax::List syntax() -{ - Syntax state("stat", QObject::tr("Shows database usage for the resources requested"), - &SinkStat::stat, Syntax::NotInteractive); - - state.addPositionalArgument({ .name = "resourceId", - .help = "Show statistics of the given resource(s). If no resource is provided, show " - "statistics of all resources", - .required = false, - .variadic = true }); - - state.completer = &SinkshUtils::resourceCompleter; - - return Syntax::List() << state; -} - -REGISTER_SYNTAX(SinkStat) - void statResource(const QString &resource, const State &state) { state.printLine("Resource " + resource + ":"); @@ -119,4 +99,22 @@ bool stat(const QStringList &args, State &state) return false; } +Syntax::List syntax() +{ + Syntax state("stat", QObject::tr("Shows database usage for the resources requested"), + &SinkStat::stat, Syntax::NotInteractive); + + state.addPositionalArgument({ .name = "resourceId", + .help = "Show statistics of the given resource(s). If no resource is provided, show " + "statistics of all resources", + .required = false, + .variadic = true }); + + state.completer = &SinkshUtils::resourceCompleter; + + return Syntax::List() << state; +} + +REGISTER_SYNTAX(SinkStat) + } diff --git a/sinksh/syntax_modules/sink_sync.cpp b/sinksh/syntax_modules/sink_sync.cpp index ee19f0a..e13e8f8 100644 --- a/sinksh/syntax_modules/sink_sync.cpp +++ b/sinksh/syntax_modules/sink_sync.cpp @@ -37,23 +37,6 @@ namespace SinkSync { -bool sync(const QStringList &args, State &state); - -Syntax::List syntax() -{ - Syntax sync("sync", QObject::tr("Synchronizes a resource."), &SinkSync::sync, Syntax::EventDriven); - - sync.addPositionalArgument({ .name = "type", .help = "The type of resource to synchronize" }); - sync.addPositionalArgument({ .name = "resourceId", .help = "The ID of the resource to synchronize" }); - sync.addParameter("password", { .name = "password", .help = "The password of the resource", .required = true }); - - sync.completer = &SinkshUtils::resourceCompleter; - - return Syntax::List() << sync; -} - -REGISTER_SYNTAX(SinkSync) - bool sync(const QStringList &args, State &state) { auto options = SyntaxTree::parseOptions(args); @@ -97,4 +80,19 @@ bool sync(const QStringList &args, State &state) return true; } +Syntax::List syntax() +{ + Syntax sync("sync", QObject::tr("Synchronizes a resource."), &SinkSync::sync, Syntax::EventDriven); + + sync.addPositionalArgument({ .name = "type", .help = "The type of resource to synchronize" }); + sync.addPositionalArgument({ .name = "resourceId", .help = "The ID of the resource to synchronize" }); + sync.addParameter("password", { .name = "password", .help = "The password of the resource", .required = true }); + + sync.completer = &SinkshUtils::resourceCompleter; + + return Syntax::List() << sync; +} + +REGISTER_SYNTAX(SinkSync) + } diff --git a/sinksh/syntax_modules/sink_trace.cpp b/sinksh/syntax_modules/sink_trace.cpp index 8636daa..2811258 100644 --- a/sinksh/syntax_modules/sink_trace.cpp +++ b/sinksh/syntax_modules/sink_trace.cpp @@ -36,28 +36,6 @@ namespace SinkTrace { -bool traceOff(const QStringList &args, State &state); -bool traceOn(const QStringList &args, State &state); -bool trace(const QStringList &args, State &state); - -Syntax::List syntax() -{ - Syntax trace("trace", QObject::tr("Control trace debug output."), &SinkTrace::trace, Syntax::NotInteractive); - trace.completer = &SinkshUtils::debugareaCompleter; - - Syntax traceOff("off", QObject::tr("Turns off trace output."), &SinkTrace::traceOff, Syntax::NotInteractive); - traceOff.completer = &SinkshUtils::debugareaCompleter; - trace.children << traceOff; - - Syntax traceOn("on", QObject::tr("Turns on trace output."), &SinkTrace::traceOn, Syntax::NotInteractive); - traceOn.completer = &SinkshUtils::debugareaCompleter; - trace.children << traceOn; - - return Syntax::List() << trace; -} - -REGISTER_SYNTAX(SinkTrace) - bool traceOff(const QStringList &args, State &state) { Sink::Log::setDebugOutputFilter(Sink::Log::Area, QByteArrayList()); @@ -88,4 +66,22 @@ bool trace(const QStringList &args, State &state) return traceOn(args, state); } +Syntax::List syntax() +{ + Syntax trace("trace", QObject::tr("Control trace debug output."), &SinkTrace::trace, Syntax::NotInteractive); + trace.completer = &SinkshUtils::debugareaCompleter; + + Syntax traceOff("off", QObject::tr("Turns off trace output."), &SinkTrace::traceOff, Syntax::NotInteractive); + traceOff.completer = &SinkshUtils::debugareaCompleter; + trace.children << traceOff; + + Syntax traceOn("on", QObject::tr("Turns on trace output."), &SinkTrace::traceOn, Syntax::NotInteractive); + traceOn.completer = &SinkshUtils::debugareaCompleter; + trace.children << traceOn; + + return Syntax::List() << trace; +} + +REGISTER_SYNTAX(SinkTrace) + } diff --git a/sinksh/syntax_modules/sink_upgrade.cpp b/sinksh/syntax_modules/sink_upgrade.cpp index 03c29ae..c399048 100644 --- a/sinksh/syntax_modules/sink_upgrade.cpp +++ b/sinksh/syntax_modules/sink_upgrade.cpp @@ -29,15 +29,6 @@ namespace SinkUpgrade { -bool upgrade(const QStringList &args, State &state); - -Syntax::List syntax() -{ - return Syntax::List() << Syntax{"upgrade", QObject::tr("Upgrades your storage to the latest version (be careful!)"), &SinkUpgrade::upgrade, Syntax::NotInteractive}; -} - -REGISTER_SYNTAX(SinkUpgrade) - bool upgrade(const QStringList &args, State &state) { state.print(QObject::tr("Upgrading...")); @@ -46,4 +37,11 @@ bool upgrade(const QStringList &args, State &state) return true; } +Syntax::List syntax() +{ + return Syntax::List() << Syntax{"upgrade", QObject::tr("Upgrades your storage to the latest version (be careful!)"), &SinkUpgrade::upgrade, Syntax::NotInteractive}; +} + +REGISTER_SYNTAX(SinkUpgrade) + } -- cgit v1.2.3