This repository was archived by the owner on Jul 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
executable file
·61 lines (51 loc) · 1.66 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
'use strict';
var program = require('commander');
var _ = require('lodash');
var version = require('./package.json').version;
var installAction = require('./src/commands/install');
var updateAction = require('./src/commands/update');
var pullAction = require('./src/commands/pull');
function noCommandRan() {
var noCommandRan = true;
_.each(program.args, function(arg) {
if (typeof arg === 'object') {
noCommandRan = false;
}
});
return noCommandRan;
}
function enumFilter() {
var args = arguments;
return function(val, defaultValue) {
for (var i = 0; i < args.length; i++) {
if (val.toLowerCase() === args[i]) {
return args[i];
}
}
return defaultValue;
}
}
program
.option('-i, --id <id>', 'Id for the keyed template to use')
.option('-d, --draft', 'Create the pull request as a draft')
.version(version);
program.command('install')
.description('Install the dependencies of this tool')
.action(installAction);
program.command('init [id]')
.description('Initialize a repo to use this tool')
.option(
'-s --source <value>',
'specify which type of source to get users from (org|collab|team)',
enumFilter('org', 'collab', 'team'),
'org')
.action(function(id, options) {
require('./src/commands/init')(id, options.source);
});
program.command('update [id]')
.description('Make adjustments to fix breaking changes when upgrading versions of pullquester')
.action(updateAction);
program.parse(process.argv);
if (noCommandRan()) {
pullAction(program.id || program.args[0], program.draft);
}