blob: fc102ff2988e7f32c39e8f8aff12f8177a830d12 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include "cmd.hpp"
#include <QCoreApplication>
int sub_bookmarks(const QStringList &l, QCoreApplication &)
{
const QCommandLineOption q("q", "something");
QCommandLineParser parser;
parser.setApplicationDescription("testing bookmarks editor");
parser.addHelpOption();
parser.addOption(q);
if(l.count() <= 1) {
parser.showHelp();
}
parser.process(l);
return 0;
}
int sub_list(const QStringList &args, QCoreApplication &)
{
for(const auto &x : args) {
qDebug("-%s", qUtf8Printable(x));
}
return 0;
}
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
app.setApplicationName("cmd_test");
app.setApplicationVersion("0.1.0");
const command_line::map<QCoreApplication> m{
{ "bookmarks", &sub_bookmarks },
{ "list", &sub_list }
};
const auto f = command_line::process<QCoreApplication>(app, m, "list");
return f(app);
}
|