-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·44 lines (39 loc) · 740 Bytes
/
Copy pathcli.js
File metadata and controls
executable file
·44 lines (39 loc) · 740 Bytes
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
#!/usr/bin/env node
import meow from 'meow';
import manageWifi from 'manage-wifi';
const cli = meow(`
Usage
$ wifi <command>
Commands
on Turn Wi-Fi on
off Turn Wi-Fi off
toggle Toggle Wi-Fi
restart Turn Wi-Fi off & on
status Wi-Fi status
device Wi-Fi device name
Examples
$ wifi off
$ wifi status
off
$ wifi device
en0
`);
const command = cli.input[0];
(async () => {
switch (command) {
case 'on':
case 'off':
case 'toggle':
case 'restart':
manageWifi[command]();
break;
case 'status':
console.log(await manageWifi.isOn() ? 'on' : 'off');
break;
case 'device':
console.log(await manageWifi.device());
break;
default:
cli.showHelp();
}
})();