summaryrefslogtreecommitdiffstats
path: root/sinksh/syntax_modules/sink_clear.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_clear.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_clear.cpp')
-rw-r--r--sinksh/syntax_modules/sink_clear.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/sinksh/syntax_modules/sink_clear.cpp b/sinksh/syntax_modules/sink_clear.cpp
index e676dd6..ca38943 100644
--- a/sinksh/syntax_modules/sink_clear.cpp
+++ b/sinksh/syntax_modules/sink_clear.cpp
@@ -35,10 +35,12 @@
35namespace SinkClear 35namespace SinkClear
36{ 36{
37 37
38Syntax::List syntax();
39
38bool clear(const QStringList &args, State &state) 40bool clear(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 clear.")); 43 state.printError(syntax()[0].usage());
42 return false; 44 return false;
43 } 45 }
44 for (const auto &resource : args) { 46 for (const auto &resource : args) {
@@ -53,6 +55,9 @@ bool clear(const QStringList &args, State &state)
53Syntax::List syntax() 55Syntax::List syntax()
54{ 56{
55 Syntax clear("clear", QObject::tr("Clears the local cache of one or more resources (be careful!)"), &SinkClear::clear, Syntax::NotInteractive); 57 Syntax clear("clear", QObject::tr("Clears the local cache of one or more resources (be careful!)"), &SinkClear::clear, Syntax::NotInteractive);
58
59 clear.addPositionalArgument({.name = "resource", .help = "The resource to clear"});
60
56 clear.completer = &SinkshUtils::resourceCompleter; 61 clear.completer = &SinkshUtils::resourceCompleter;
57 62
58 return Syntax::List() << clear; 63 return Syntax::List() << clear;