-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
73 lines (59 loc) · 2.14 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
#!/usr/bin/env node
var path = require('path');
var pkg = require(path.join(__dirname, 'package.json'));
var program = require('commander');
program.version('1.0.0')
.option(
'-s, --store <store>',
'use the specified store',
(process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE) + "/.octools/store.json" )
.option(
'-v, --verbose',
'verbose mode' );
var OcTools = require('./lib/octools.js');
var octools = new OcTools();
octools.store(program.store);
if (program.verbose) {
console.log('Store is ' + octools.store);
}
program.command('tokens').description('list tokens').action(function() {
octools.tokens();
});
program.command('install <token>').description(
'install one or more tokens in the store').action(function(token) {
if ( program.verbose )
console.log('install "%s"', token);
octools.addToken( token );
});
program.command('remove <token>').description(
'remove one token from the store').action(function(token) {
if ( program.verbose )
console.log('remove "%s"', token);
octools.removeToken( token );
});
program.command('refresh').description(
'refresh org and servers for all the tokens)').action(function() {
if ( program.verbose )
console.log('refresh');
octools.refresh();
});
program.command('generate <scope> <type>').description(
'generate for the given scope ("all" or a name) and type ("ansible" or "dns")').action(function(scope,type) {
if ( program.verbose )
console.log('generate "%s" "%s"', scope,type);
octools.generate(scope,type);
});
program.command('get <scope> [type]').description(
'get the infos for the given scope ("all" or a name) and type ("org" or "server")').action(
function(scope,type) {
if ( program.verbose )
console.log('get "%s"%s',scope, ( type != null ? " of type " + type : ""));
octools.get(scope,type);
});
program.command('dump <resource> [scope]').description(
'dump full information for the given resource for all or the specified token)').action(function( resource, scope ) {
if ( program.verbose )
console.log('dump %s', resource);
octools.dump( resource, scope );
});
program.parse(process.argv);