Repository navigation
Expand file tree
/
Copy pathmain.js
More file actions
81 lines (73 loc) · 3.08 KB
/
Copy pathmain.js
File metadata and controls
81 lines (73 loc) · 3.08 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const redis = require("redis");
var log = require('winston');
var program = require('commander');
var assign = require('object-assign');
var pjson = require('../package.json');
var app = require('../index.js');
// Creates a new Redis client
// If REDIS_HOST is not set, the default host is localhost
// If REDIS_PORT is not set, the default port is 6379
const redisClient = redis.createClient({
url: `redis://${process.env.REDIS_HOST}:${process.env.REDIS_PORT}`
});
redisClient.on("error", (err) => console.log("Error", err));
program.version(pjson.version)
.usage('[options] <doxygen directory>')
.option('-o, --output <file>', 'output file (must contain %s when using groups)', String, 'api.md')
.option('-g, --groups', 'output doxygen groups into separate files', false)
.option('-c, --classes', 'output doxygen groups into separate files', false)
.option('-p, --pages', 'output doxygen pages into separate files', false)
.option('-n, --noindex', 'disable generation of the index (no effect with `groups` option', false)
.option('-a, --anchors', 'add anchors to internal links', false)
.option('-h, --html-anchors', 'add html anchors to internal links', false)
.option('-l, --language <lang>', 'programming language', String, 'cpp')
.option('-t, --templates <dir>', 'custom templates directory', String, 'templates')
.option('-q, --quiet', 'quiet mode', false)
.parse(process.argv);
if (!program.quiet) {
log.level = 'verbose';
}
if (program.args.length) {
app.run(assign({}, app.defaultOptions, {
directory: program.args[0],
output: program.output,
groups: program.groups,
pages: program.pages,
classes: program.classes,
noindex: program.noindex,
anchors: program.anchors,
htmlAnchors: program.htmlAnchors,
language: program.language,
templates: program.templates
}));
}
else {
program.help();
}
(async () => {
await redisClient.connect();
// Sets the key "octocat" to a value of "Mona the octocat"
const setKeyReply = await redisClient.set("octocat", "Mona the Octocat");
console.log("Reply: " + setKeyReply);
// Sets a key to "species", field to "octocat", and "value" to "Cat and Octopus"
const SetFieldOctocatReply = await redisClient.hSet("species", "octocat", "Cat and Octopus");
console.log("Reply: " + SetFieldOctocatReply);
// Sets a key to "species", field to "dinotocat", and "value" to "Dinosaur and Octopus"
const SetFieldDinotocatReply = await redisClient.hSet("species", "dinotocat", "Dinosaur and Octopus");
console.log("Reply: " + SetFieldDinotocatReply);
// Sets a key to "species", field to "robotocat", and "value" to "Cat and Robot"
const SetFieldRobotocatReply = await redisClient.hSet("species", "robotocat", "Cat and Robot");
console.log("Reply: " + SetFieldRobotocatReply);
try {
// Gets all fields in "species" key
const replies = await redisClient.hKeys("species");
console.log(replies.length + " replies:");
replies.forEach((reply, i) => {
console.log(" " + i + ": " + reply);
});
await redisClient.quit();
}
catch (err) {
// statements to handle any exceptions
}
})();