diff options
Diffstat (limited to 'sinksh/syntax_modules/sink_clear.cpp')
-rw-r--r-- | sinksh/syntax_modules/sink_clear.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/sinksh/syntax_modules/sink_clear.cpp b/sinksh/syntax_modules/sink_clear.cpp new file mode 100644 index 0000000..d02c638 --- /dev/null +++ b/sinksh/syntax_modules/sink_clear.cpp | |||
@@ -0,0 +1,61 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | |||
20 | #include <QDebug> | ||
21 | #include <QObject> // tr() | ||
22 | #include <QTimer> | ||
23 | |||
24 | #include "common/resource.h" | ||
25 | #include "common/storage.h" | ||
26 | #include "common/domain/event.h" | ||
27 | #include "common/domain/folder.h" | ||
28 | #include "common/resourceconfig.h" | ||
29 | #include "common/log.h" | ||
30 | #include "common/storage.h" | ||
31 | #include "common/definitions.h" | ||
32 | |||
33 | #include "sinksh_utils.h" | ||
34 | #include "state.h" | ||
35 | #include "syntaxtree.h" | ||
36 | |||
37 | namespace SinkClear | ||
38 | { | ||
39 | |||
40 | bool clear(const QStringList &args, State &state) | ||
41 | { | ||
42 | for (const auto &resource : args) { | ||
43 | state.print(QObject::tr("Removing local cache for '%1' ...").arg(resource)); | ||
44 | Sink::Store::removeFromDisk(resource.toLatin1()); | ||
45 | state.printLine(QObject::tr("done")); | ||
46 | } | ||
47 | |||
48 | return true; | ||
49 | } | ||
50 | |||
51 | Syntax::List syntax() | ||
52 | { | ||
53 | Syntax clear("clear", QObject::tr("Clears the local cache of one or more resources (be careful!)"), &SinkClear::clear); | ||
54 | clear.completer = &SinkshUtils::resourceCompleter; | ||
55 | |||
56 | return Syntax::List() << clear; | ||
57 | } | ||
58 | |||
59 | REGISTER_SYNTAX(SinkClear) | ||
60 | |||
61 | } | ||