forked from magnew/splunk_viz_tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
splunk_viz_tasks.js
86 lines (85 loc) · 2.85 KB
/
splunk_viz_tasks.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
var yargs = require('yargs');
vizBuilder = require('./splunk_viz_builder.js');
var argv = yargs.usage('$0 command')
// Source commands
.command('list_apps', 'lists visualization apps', function(yargs){
var sourceTasks = vizBuilder.getSourceTasks();
if(sourceTasks){
sourceTasks.listAppDirectories();
}
else {
console.log('No splunk app source found, bailing');
}
})
.command('build_all_viz', 'lists visualization apps', function(yargs){
var sourceTasks = vizBuilder.getSourceTasks();
if(sourceTasks){
sourceTasks.buildAllVisualizations();
}
else {
console.log('No splunk app source found, bailing');
}
})
.command('build_all_apps', 'builds a splunk app package for each app', function(yargs){
var sourceTasks = vizBuilder.getSourceTasks();
if(sourceTasks){
sourceTasks.buildAllApps();
}
else {
console.log('No splunk app source found, bailing');
}
})
.command('build_app', 'builds a splunk app package', function(yargs){
var sourceTasks = vizBuilder.getSourceTasks();
if(sourceTasks) {
var appName = yargs.argv._[1]
if(appName) {
sourceTasks.buildApp(appName);
}
else {
console.log('Error: must specify an app');
}
}
else {
console.log('No splunk app source found, bailing');
}
})
// App commands
.command('list_app_viz', 'lists app visualization packages', function(yargs){
var appTasks = vizBuilder.getAppTasks();
if(appTasks){
appTasks.listAppVisualizations();
}
else {
console.log('This does not appear to be an app directory, bailing');
}
})
.command('build_app_viz', 'builds app visualizations by name', function(yargs){
var appTasks = vizBuilder.getAppTasks();
if(appTasks) {
var vizName = yargs.argv._[1];
if(vizName){
appTasks.buildAppVisualization(vizName);
}
else {
console.log('No visualization specified, building all visualizations in app');
appTasks.buildAllAppVisualizations()
}
}
else {
console.log('This does not appear to be an app directory, bailing');
}
})
.command('build_all_app_viz', 'builds app visualizations', function(yargs){
var appTasks = vizBuilder.getAppTasks();
if(appTasks){
appTasks.buildAllAppVisualizations();
}
else {
console.log('This does not appear to be an app directory, bailing');
}
})
.demand(1, 'must provide a valid command')
.help('h')
.alias('h', 'help')
.argv