summaryrefslogtreecommitdiffstats
path: root/sinksh/syntax_modules/sink_drop.cpp
diff options
context:
space:
mode:
authorRémi Nicole <nicole@kolabsystems.com>2018-08-03 16:59:16 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-08-03 17:10:31 +0200
commit50bed81038f10091d35c5719df8078612393ae95 (patch)
treee4a3b634118b2b1b9fd88203902e934299deac9b /sinksh/syntax_modules/sink_drop.cpp
parentad3dc221273100ba61828f993f1d1c8a1272d665 (diff)
downloadsink-50bed81038f10091d35c5719df8078612393ae95.tar.gz
sink-50bed81038f10091d35c5719df8078612393ae95.zip
Improve documentation of SinkSH
Summary: - Add support for positional arguments, options, flags in the syntax tree - Add automatic generation of usage string TODO: - ~~Better document the `--reduce` option in the `list` command~~ - Get the parent command for sub-commands so we could show help for `trace on` and not just `on` - Pass the syntax to the implementation of the command so commands can easily show help on wrong usage. Also, SyntaxTree could do automatic input validation in the future, this could also help. - Even with the new documentation, some command could still be confusing. Should we add some usage examples? Reviewers: cmollekopf Reviewed By: cmollekopf Tags: #sink Differential Revision: https://phabricator.kde.org/D14547
Diffstat (limited to 'sinksh/syntax_modules/sink_drop.cpp')
-rw-r--r--sinksh/syntax_modules/sink_drop.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/sinksh/syntax_modules/sink_drop.cpp b/sinksh/syntax_modules/sink_drop.cpp
index 3b9a817..eaa3041 100644
--- a/sinksh/syntax_modules/sink_drop.cpp
+++ b/sinksh/syntax_modules/sink_drop.cpp
@@ -35,10 +35,12 @@
35namespace SinkDrop 35namespace SinkDrop
36{ 36{
37 37
38Syntax::List syntax();
39
38bool drop(const QStringList &args, State &state) 40bool drop(const QStringList &args, State &state)
39{ 41{
40 if (args.isEmpty()) { 42 if (args.isEmpty()) {
41 state.printError(QObject::tr("Please provide at least one resource to drop.")); 43 state.printError(syntax()[0].usage());
42 return false; 44 return false;
43 } 45 }
44 46
@@ -60,6 +62,8 @@ bool drop(const QStringList &args, State &state)
60Syntax::List syntax() 62Syntax::List syntax()
61{ 63{
62 Syntax drop("drop", QObject::tr("Drop all caches of a resource."), &SinkDrop::drop, Syntax::NotInteractive); 64 Syntax drop("drop", QObject::tr("Drop all caches of a resource."), &SinkDrop::drop, Syntax::NotInteractive);
65 drop.addPositionalArgument({.name = "resource", .help = "Id(s) of the resource(s) to drop", .required = true, .variadic = true});
66
63 drop.completer = &SinkshUtils::resourceOrTypeCompleter; 67 drop.completer = &SinkshUtils::resourceOrTypeCompleter;
64 return Syntax::List() << drop; 68 return Syntax::List() << drop;
65} 69}