summaryrefslogtreecommitdiffstats
path: root/sinksh/syntax_modules/sink_create.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sinksh/syntax_modules/sink_create.cpp')
-rw-r--r--sinksh/syntax_modules/sink_create.cpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/sinksh/syntax_modules/sink_create.cpp b/sinksh/syntax_modules/sink_create.cpp
index f18a990..b1631cd 100644
--- a/sinksh/syntax_modules/sink_create.cpp
+++ b/sinksh/syntax_modules/sink_create.cpp
@@ -40,15 +40,12 @@ using namespace Sink;
40namespace SinkCreate 40namespace SinkCreate
41{ 41{
42 42
43Syntax::List syntax();
44
43bool create(const QStringList &allArgs, State &state) 45bool create(const QStringList &allArgs, State &state)
44{ 46{
45 if (allArgs.isEmpty()) {
46 state.printError(QObject::tr("A type is required"), "sinkcreate/02");
47 return false;
48 }
49
50 if (allArgs.count() < 2) { 47 if (allArgs.count() < 2) {
51 state.printError(QObject::tr("A resource ID is required to create items"), "sinkcreate/03"); 48 state.printError(syntax()[0].usage());
52 return false; 49 return false;
53 } 50 }
54 51
@@ -173,15 +170,33 @@ bool identity(const QStringList &args, State &state)
173 return true; 170 return true;
174} 171}
175 172
176
177Syntax::List syntax() 173Syntax::List syntax()
178{ 174{
179 Syntax::List syntax; 175 Syntax::List syntax;
180 176
181 Syntax create("create", QObject::tr("Create items in a resource"), &SinkCreate::create); 177 Syntax create("create", QObject::tr("Create items in a resource"), &SinkCreate::create);
182 create.children << Syntax("resource", QObject::tr("Creates a new resource"), &SinkCreate::resource); 178 create.addPositionalArgument({ .name = "type", .help = "The type of entity to create (mail, event, etc.)" });
183 create.children << Syntax("account", QObject::tr("Creates a new account"), &SinkCreate::account); 179 create.addPositionalArgument({ .name = "resourceId", .help = "The ID of the resource that will contain the new entity" });
184 create.children << Syntax("identity", QObject::tr("Creates a new identity"), &SinkCreate::identity); 180 create.addPositionalArgument(
181 { .name = "key value", .help = "Content of the entity", .required = false, .variadic = true });
182
183 Syntax resource("resource", QObject::tr("Creates a new resource"), &SinkCreate::resource);
184 resource.addPositionalArgument({ .name = "type", .help = "The type of resource to create" });
185 resource.addPositionalArgument(
186 { .name = "key value", .help = "Content of the resource", .required = false, .variadic = true });
187
188 Syntax account("account", QObject::tr("Creates a new account"), &SinkCreate::account);
189 account.addPositionalArgument({ .name = "type", .help = "The type of account to create" });
190 account.addPositionalArgument(
191 { .name = "key value", .help = "Content of the account", .required = false, .variadic = true });
192
193 Syntax identity("identity", QObject::tr("Creates a new identity"), &SinkCreate::identity);
194 identity.addPositionalArgument(
195 { .name = "key value", .help = "Content of the identity", .required = false, .variadic = true });
196
197 create.children << resource;
198 create.children << account;
199 create.children << identity;
185 200
186 syntax << create; 201 syntax << create;
187 return syntax; 202 return syntax;