summaryrefslogtreecommitdiffstats
path: root/sinksh/syntax_modules/sink_stat.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_stat.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_stat.cpp')
-rw-r--r--sinksh/syntax_modules/sink_stat.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/sinksh/syntax_modules/sink_stat.cpp b/sinksh/syntax_modules/sink_stat.cpp
index 7263941..a936af2 100644
--- a/sinksh/syntax_modules/sink_stat.cpp
+++ b/sinksh/syntax_modules/sink_stat.cpp
@@ -69,7 +69,6 @@ void statResource(const QString &resource, const State &state)
69 state.printLine(QObject::tr("Actual database file sizes total: %1 [kb]").arg(size), 1); 69 state.printLine(QObject::tr("Actual database file sizes total: %1 [kb]").arg(size), 1);
70 70
71 QDir dataDir{Sink::resourceStorageLocation(resource.toLatin1()) + "/fulltext/"}; 71 QDir dataDir{Sink::resourceStorageLocation(resource.toLatin1()) + "/fulltext/"};
72 Q_ASSERT(dataDir.exists());
73 qint64 dataSize = 0; 72 qint64 dataSize = 0;
74 for (const auto &e : dataDir.entryInfoList(QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot)) { 73 for (const auto &e : dataDir.entryInfoList(QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot)) {
75 dataSize += e.size(); 74 dataSize += e.size();
@@ -102,7 +101,15 @@ bool stat(const QStringList &args, State &state)
102 101
103Syntax::List syntax() 102Syntax::List syntax()
104{ 103{
105 Syntax state("stat", QObject::tr("Shows database usage for the resources requested"), &SinkStat::stat, Syntax::NotInteractive); 104 Syntax state("stat", QObject::tr("Shows database usage for the resources requested"),
105 &SinkStat::stat, Syntax::NotInteractive);
106
107 state.addPositionalArgument({ .name = "resourceId",
108 .help = "Show statistics of the given resource(s). If no resource is provided, show "
109 "statistics of all resources",
110 .required = false,
111 .variadic = true });
112
106 state.completer = &SinkshUtils::resourceCompleter; 113 state.completer = &SinkshUtils::resourceCompleter;
107 114
108 return Syntax::List() << state; 115 return Syntax::List() << state;