This repository was archived by the owner on Apr 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·107 lines (100 loc) · 2.65 KB
/
cli.js
File metadata and controls
executable file
·107 lines (100 loc) · 2.65 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env node
'use strict';
const yargs = require('yargs');
const autostart = require('./index.js');
yargs
.usage('Usage: $0 <command> [options]')
.command('enable', 'Enable autostart here with a custom key', (yargs, argv) => {
argv = yargs
.option('n', {
demand: true,
alias: 'name',
describe: 'Name of the key for identifying startup objects',
type: 'string',
nargs: 1
})
.option('c', {
demand: false,
alias: 'command',
describe: 'Command to execute in the path',
type: 'string',
default: 'npm start'
})
.option('p', {
demand: false,
alias: 'path',
describe: 'Place of execution of command',
type: 'string',
default: process.cwd()
})
.help('h')
.alias('h', 'help')
.showHelpOnFail(false, 'Use --help for further information')
.argv;
autostart.enableAutostart(argv.n, argv.c, argv.p, err => {
if (err) {
console.error('An error occured while trying to enable autostart, here are the details:');
console.error(err);
process.exit(1);
}
console.log('Done!');
process.exit(0);
});
})
.command('disable', 'Disable autostart with key', (yargs, argv) => {
argv = yargs
.option('n', {
demand: true,
alias: 'name',
describe: 'Name of the key for identifying startup objecst',
type: 'string',
nargs: 1
})
.help('h')
.alias('h', 'help')
.showHelpOnFail(false, 'Use --help for further information')
.argv;
autostart.disableAutostart(argv.n, err => {
if (err) {
console.error('An error occured while trying to disable autostart, here are the details:');
console.error(err);
process.exit(1);
}
console.log('Done!');
process.exit(0);
});
})
.command('check', 'Check if autostart is enabled by key', (yargs, argv) => {
argv = yargs
.option('n', {
demand: true,
alias: 'name',
describe: 'Name of the key for identifying startup objects',
type: 'string',
nargs: 1
})
.help('h')
.alias('h', 'help')
.showHelpOnFail(false, 'Use --help for further information')
.argv;
autostart.isAutostartEnabled(argv.n, (err, isEnabled) => {
if (err) {
console.error('An error occured, here are the details:');
console.error(err);
process.exit(1);
}
console.log('Done!');
if (isEnabled) {
console.log('Autostart is enabled');
process.exit(0);
} else if (!isEnabled) {
console.log('Autostart is not enabled');
process.exit(0);
}
});
})
.demand(1)
.help('h')
.alias('h', 'help')
.showHelpOnFail(false, 'Use --help for further information')
.argv;