-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
39 lines (34 loc) · 1.3 KB
/
index.js
File metadata and controls
39 lines (34 loc) · 1.3 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
/*jshint node:true*/
'use strict';
var fs = require('q-io/fs');
var settingsF = require('./src/settings');
var auth = settingsF(fs, process.cwd() + '/auth.json');
var config = settingsF(fs, process.cwd() + '/codebase-config.json');
var codebase = require('./src/codebase.js')(auth, config, fs);
var serializer = require('./src/serializer.js')();
var workflow = require('./src/workflow')(codebase,serializer, config.get().get('commands'));
var query = process.argv[2] || '';
query = query.trim().toLowerCase();
var tokens = query.split('>').map(function (string) {
return string.trim();
});
auth.get().then(function (authInfo) {
if (query[0] === '>') {
//Explicit command request "> login"
workflow.showCommandList(tokens[1]);
} else if (!authInfo.user || !authInfo.pass) {
auth.set('pass', '').then(function () {
return auth.set('user', '');
}).then(function () {
workflow.showCommandList(tokens[0]);
});
} else if (tokens.length === 2) {
//Per-project opened ticket listing "my-project > query"
var project = tokens[0];
query = tokens[1] || '';
workflow.showTicketList(project, query);
} else if (tokens.length === 1) {
//Project listing "query"
workflow.showProjectList(query);
}
});