-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcli.js
36 lines (32 loc) · 1.18 KB
/
cli.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
#!/usr/bin/env node
'use strict';
var meow = require('meow');
var chalk = require('chalk');
var notepadReplacer = require('./');
var cli = meow({
help: [
'Usage',
' notepad-replacer [--install <editor.exe>] [--contextmenu <name>] [--uninstall]',
'',
'When no install/uninstall flag is used, it invokes your configured replacement and forwards any parameters.',
'--install <path-to-editor-exe> Enables the notepad replacement.',
'--contextmenu <name> Adds a content menu entry (only valid in )',
'--uninstall Disables the notepad replacement.',
''
].join('\n')
});
var promise;
if (cli.flags.contextmenu && !cli.flags.install) {
console.error(chalk.red.bold('Parameter --contextmenu is only valid in conjunction with --install.'));
} else if (cli.flags.install) {
promise = notepadReplacer.install(cli.flags.install, cli.flags.contextmenu);
} else if (cli.flags.uninstall) {
promise = notepadReplacer.uninstall();
} else {
promise = notepadReplacer.invoke(process.argv);
}
if (promise) {
promise.catch(function(err) {
console.error(chalk.red.bold('Error: ' + err.message));
});
}