-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
97 lines (85 loc) · 1.97 KB
/
app.js
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env node
const wallpaper = require("wallpaper");
const program = require("commander");
const setMomentun = require("./src/saveMomenImage");
const setBing = require("./src/saveBingImage");
const fs = require("fs");
const fss = require("fs-extra");
const initProgram = require("./src/init");
const openExplorer = require("open-in-explorer");
const {
bingUrl,
momentumUrl,
originUrl,
dataStoreFile,
homeDir
} = require("./config/constants");
const Store = require("data-store");
const store = new Store({ path: dataStoreFile });
initProgram();
program.version("1.6.2");
program
.command("use <name>")
.description("change wallpaper to bing or momentum")
.action(name => {
if (name === "bing") {
if (fs.existsSync(bingUrl)) {
(async () => {
await wallpaper.set(bingUrl);
})();
} else {
setBing();
}
} else if (name === "momentum") {
if (fs.existsSync(momentumUrl)) {
(async () => {
await wallpaper.set(momentumUrl);
})();
} else {
setMomentun();
}
}
});
program
.command("reset")
.description("reset wallpaper")
.action(() => {
(async () => {
await wallpaper.set(originUrl);
})();
});
program
.command("clean")
.description("delete today's wallpaper")
.action(() => {
(async () => {
await fss.remove(bingUrl);
await fss.remove(momentumUrl);
console.log("clean success!");
})();
});
program
.command("set-id <id>")
.description("set momentum uuid")
.action(id => {
store.set("uuid", id);
});
program
.command("set-area <code>")
.description("set bing area")
.action(code => {
store.set("area", code);
});
program
.command("open")
.description("open picture folder in explorer")
.action(() => {
openExplorer(homeDir);
});
program.command("*").action(() => {
console.log("No Such Command !");
});
program.parse(process.argv);
if (process.argv.length <= 2) {
program.help();
}