-
Notifications
You must be signed in to change notification settings - Fork 0
/
program.js
executable file
·46 lines (43 loc) · 1.19 KB
/
program.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
#!/usr/bin/env node
const { program } = require("commander");
const {
checkCurrentStatus,
setCurrentStatus,
setDND,
clearCurrentStatus,
clearDND,
formatStatusExpiration,
} = require("./processes");
program
.option("-c, --current", "Check current status")
.option("-hd, --headsdown", "Preconfigured 'Heads down' status")
.option("-m, --minutes", "Minutes to be not disturbed")
.option("-x, --clear", "Clear status")
.option(
"-dnd, --snooze",
`Do not disturb (Snooze notifications)
Enter amount of minutes to snooze, or will default to 30min
ex: "status -dnd 45"
`
)
.option("-w, --wake", "End snooze (Do not disturb)")
.parse(process.argv);
const { args } = program;
const opts = program.opts();
const { current, headsdown, clear, wake, snooze } = opts;
if (current) {
checkCurrentStatus();
} else if (headsdown) {
setCurrentStatus({
status_text: "heads down",
status_emoji: ":heads-down:",
status_expiration: args.length < 1 ? 0 : formatStatusExpiration(args[0]),
});
setDND(args.length < 1 ? 30 : args[0]);
} else if (clear) {
clearCurrentStatus();
} else if (snooze) {
setDND(args.length < 1 ? 30 : args[0]);
} else if (wake) {
clearDND();
}