-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
102 lines (88 loc) · 3.42 KB
/
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
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
#!/usr/bin/env node
const program = require(`commander`);
const pkg = require(__dirname + `/package`);
const lib = require(__dirname + `/lib`);
program
.version(pkg.version)
.description(pkg.description);
program
.command(`init <username> <token> <remoteUri>`)
.description(`Initialize this utility`)
.action((username, token, remoteUri) => {
lib.getScript(`init`)(username, token, remoteUri);
});
program
.command(`macro`)
.option(`-t, --title <title>`, `Set title of macro`)
.option(`-f, --file <path>`, `Path to comment text file`)
.option(`-w, --write`, `Open editor to write comment content`)
.option(`-T, --tags <tags>`, `Append tags (space delineated)`)
.option(`-i, --inactive`, `Make macro inactive`)
.option(`-y, --type <type>`, `Set the type`)
.option(`-S, --status <status>`, `Set the status`)
.option(`-p, --private`, `Set comment mode to private`)
.option(`-l, --list`, `List all macros`)
.option(`-e, --export [file_name]`, `Export all macros to JSON file`)
.option(`-x, --sort <sort_by>`, `Sort macros in list or export`)
.option(`-u, --update <macro_id>`, `Update a single macro`, parseInt)
.option(`-b, --bulk-update <file>`, `Bulk update macros using data from specified JSON file`)
.option(`-o, --open [macro_id]`, `Open the macro in ZenDesk`, parseInt)
.description(`Add, update, list, open macros`)
.action((options) => {
lib.getScript(`macro`)(options);
});
program
.command('add <type>')
.option(`-t, --title <title>`, `Set title of macro`)
.option(`-f, --file <path>`, `Path to comment text file`)
.option(`-w, --write`, `Open editor to write comment content`)
.option(`-T, --tags <tags>`, `Append tags (space delineated)`)
.option(`-y, --type <type>`, `Set the type`)
.option(`-S, --status <status>`, `Set the status`)
.option(`-i, --inactive`, `Make macro inactive`)
.option(`-p, --private`, `Set comment mode to private`)
.option(`-o, --open`, `Open the macro in browser after creating`)
.description(`Add a macro or article`)
.action((type, options) => {
lib.getScript(type)(options);
});
program
.command(`update <type> <id>`)
.option(`-t, --title <title>`, `Set title of macro`)
.option(`-f, --file <path>`, `Path to comment text file`)
.option(`-w, --write`, `Open editor to write comment content`)
.option(`-T, --tags <tags>`, `Append tags (space delineated)`)
.option(`-i, --inactive`, `Make macro inactive`)
.option(`-p, --private`, `Set comment mode to private`)
.option(`-o, --open`, `Open the macro in browser after updating`)
.description(`Update a macro`)
.action((type, id, options) => {
options.update = parseInt(id);
lib.getScript(type)(options);
});
program
.command(`list <type>`)
.description(`Add a macro to ZenDesk`)
.description(`List macros or articles.`)
.action((type) => {
var options = {
list: true
};
if (type === 'macros') {
type = 'macro';
}
if (type === 'articles') {
type = 'article';
}
lib.getScript(type)(options);
});
program
.command(`open <type> <id>`)
.description(`Open a macro or article in the browser`)
.action((type, id) => {
var options = {
open: parseInt(id)
};
lib.getScript(type)(options);
});
program.parse(process.argv);