-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpoeditor-config.js
More file actions
46 lines (35 loc) · 1.17 KB
/
poeditor-config.js
File metadata and controls
46 lines (35 loc) · 1.17 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
var program = require('commander'),
utils = require('./utils'),
clc = require('cli-color');
program.version("1.0.0")
.description("Perform some configurations")
.option("-g, --global", "Get or set global configuration");
program.command('set [key] [value]')
.description('Set a configuration')
.action(setConfiguration);
program.command('unset [key]')
.description('Unset a configuration')
.action(unsetConfiguration);
program.command('get [key]')
.description('Get a configuration')
.action(getConfiguration);
program.parse(process.argv);
function setConfiguration(key, value){
if(program.global){
utils.setGlobalConfiguration(key, value);
} else {
utils.setLocalConfiguration(key, value);
}
console.log(clc.green("[OK] Successfully set " + (program.global ? 'global' : 'local') + " configuration."));
}
function unsetConfiguration(key){
setConfiguration(key, undefined);
}
function getConfiguration(key){
var config = program.global ? utils.getGlobalConfiguration() : utils.getLocalConfiguration();
if(!config[key]){
console.log(clc.red("[ERROR] Configuration not found."));
process.exit(0);
}
console.log("\n " + key + " => " + config[key]);
}