UNPKG

1.02 kBPlain TextView Raw
1#!/usr/bin/env node
2
3var program = require('commander'),
4 logger = require('../lib/logger'),
5 beanstalk = require('../lib/api'),
6 config = require("../lib/config").get();
7
8/*
9 |--------------------------------------------------------------------------
10 | Program
11 |--------------------------------------------------------------------------
12 */
13program
14 .usage('<repo> [color]')
15 .parse(process.argv);
16
17var repoName = program.args[0],
18 color = program.args[1];
19
20if (!repoName) {
21 logger.fatal('You need to pass in the <repo> argument.');
22}
23
24if (color) {
25 if(!beanstalk.isValidColor(color)){
26 logger.fatal('The given color is not valid.');
27 logger.warn('Available colors : ', beanstalk.availableColors().join(', '));
28 process.exit(1);
29 }
30}
31
32beanstalk.createRepo(repoName, color, function(repo){
33 logger.success('Repository created successfully.');
34 logger.info('Web url: ' + 'https://'+ config.account +'.beanstalkapp.com/' + repoName);
35 logger.info('Git url: ' + repo.repository_url);
36});