From 50bed81038f10091d35c5719df8078612393ae95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Nicole?= Date: Fri, 3 Aug 2018 16:59:16 +0200 Subject: 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 --- sinksh/syntax_modules/sink_clear.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sinksh/syntax_modules/sink_clear.cpp') 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 @@ namespace SinkClear { +Syntax::List syntax(); + bool clear(const QStringList &args, State &state) { if (args.isEmpty()) { - state.printError(QObject::tr("Please provide at least one resource to clear.")); + state.printError(syntax()[0].usage()); return false; } for (const auto &resource : args) { @@ -53,6 +55,9 @@ 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; -- cgit v1.2.3