-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·48 lines (37 loc) · 948 Bytes
/
index.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
#!/usr/bin/env node
'use strict'
const { isOn, toggle } = require('toggle-hotplug')
const meow = require('meow')
const shoutMessage = require('shout-message')
const updateNotifier = require('update-notifier')
const cli = meow(
`
Usage:
$ hotplug <cmd>
Example:
$ hotplug toggle hotplug on and off
$ hotplug status show hotplug status
Options:
-h, --help show help options
-v, --version show version
`,
{
alias: {
h: 'help',
v: 'version'
}
}
)
updateNotifier({ pkg: cli.pkg }).notify()
const run = async () => {
const input = cli.input[0]
if (input === 'status') {
const result = await isOn()
const status = result ? 'hotplug is `on`.' : 'hotplug is `off`.'
return shoutMessage(status)
}
const result = await toggle()
const status = `You just turned ${result ? '`on`' : '`off`'} hotplug.`
shoutMessage(status)
}
run()