summaryrefslogtreecommitdiffstats
path: root/sinksh/syntax_modules/sink_stat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sinksh/syntax_modules/sink_stat.cpp')
-rw-r--r--sinksh/syntax_modules/sink_stat.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/sinksh/syntax_modules/sink_stat.cpp b/sinksh/syntax_modules/sink_stat.cpp
index 7263941..235558f 100644
--- a/sinksh/syntax_modules/sink_stat.cpp
+++ b/sinksh/syntax_modules/sink_stat.cpp
@@ -36,6 +36,26 @@
36namespace SinkStat 36namespace SinkStat
37{ 37{
38 38
39bool stat(const QStringList &args, State &state);
40
41Syntax::List syntax()
42{
43 Syntax state("stat", QObject::tr("Shows database usage for the resources requested"),
44 &SinkStat::stat, Syntax::NotInteractive);
45
46 state.addPositionalArgument({ .name = "resourceId",
47 .help = "Show statistics of the given resource(s). If no resource is provided, show "
48 "statistics of all resources",
49 .required = false,
50 .variadic = true });
51
52 state.completer = &SinkshUtils::resourceCompleter;
53
54 return Syntax::List() << state;
55}
56
57REGISTER_SYNTAX(SinkStat)
58
39void statResource(const QString &resource, const State &state) 59void statResource(const QString &resource, const State &state)
40{ 60{
41 state.printLine("Resource " + resource + ":"); 61 state.printLine("Resource " + resource + ":");
@@ -69,7 +89,6 @@ void statResource(const QString &resource, const State &state)
69 state.printLine(QObject::tr("Actual database file sizes total: %1 [kb]").arg(size), 1); 89 state.printLine(QObject::tr("Actual database file sizes total: %1 [kb]").arg(size), 1);
70 90
71 QDir dataDir{Sink::resourceStorageLocation(resource.toLatin1()) + "/fulltext/"}; 91 QDir dataDir{Sink::resourceStorageLocation(resource.toLatin1()) + "/fulltext/"};
72 Q_ASSERT(dataDir.exists());
73 qint64 dataSize = 0; 92 qint64 dataSize = 0;
74 for (const auto &e : dataDir.entryInfoList(QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot)) { 93 for (const auto &e : dataDir.entryInfoList(QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot)) {
75 dataSize += e.size(); 94 dataSize += e.size();
@@ -100,14 +119,4 @@ bool stat(const QStringList &args, State &state)
100 return false; 119 return false;
101} 120}
102 121
103Syntax::List syntax()
104{
105 Syntax state("stat", QObject::tr("Shows database usage for the resources requested"), &SinkStat::stat, Syntax::NotInteractive);
106 state.completer = &SinkshUtils::resourceCompleter;
107
108 return Syntax::List() << state;
109}
110
111REGISTER_SYNTAX(SinkStat)
112
113} 122}