summaryrefslogtreecommitdiff
path: root/mongo-edu.js
diff options
context:
space:
mode:
Diffstat (limited to 'mongo-edu.js')
-rw-r--r--mongo-edu.js41
1 files changed, 14 insertions, 27 deletions
diff --git a/mongo-edu.js b/mongo-edu.js
index 33d8802..fcee4ef 100644
--- a/mongo-edu.js
+++ b/mongo-edu.js
@@ -6,42 +6,25 @@
* https://github.com/przemyslawpluta/mongo-edu/blob/master/LICENSE
*/
-var mdbvideos = require('./lib/login'),
+var pkg = require('./package'),
+ mdbvideos = require('./lib/login'),
videoHandler = require('./lib/videos'),
validate = require('./lib/validate'),
configure = require('./lib/configure'),
+ optArgs = require('./lib/options'),
+ yargs = optArgs.build(),
url = require('url'),
path = require('path'),
colors = require('colors'),
- inquirer = require('inquirer'),
- yargs = require('yargs')
- .usage('Usage: $0 [options]')
- .describe('d', 'download path').describe('u', 'email address')
- .describe('h', 'switch from videos (default) to handouts').boolean('h')
- .describe('py', 'py switch').describe('py', 'switch to point to Python')
- .describe('proxy', 'pass proxy').describe('proxy', 'pass proxy switch for video download')
- .describe('test', 'proxy test').describe('test', 'use with --proxy to test if usable')
- .describe('cw', 'switch from wiki\'s video lists (default) to courseware').boolean('cw')
- .describe('cwd', 'same as --cw and dumps list of videos to file in -d').boolean('cwd')
- .describe('cc', 'get closed captions').boolean('cc')
- .describe('hq', 'get high quality videos').boolean('hq')
- .describe('ncc', 'no check certificate').boolean('ncc')
- .describe('uz', 'unzip handout files').boolean('uz')
- .describe('co', 'sequence video files in order of the courseware').boolean('co')
- .describe('verbose', 'print debug information').boolean('verbose')
- .example('$0 -d your_download_path', 'download videos from wiki')
- .example('$0 -d your_download_path -u your_user_name --cw --hq --cc', 'download high quality videos from courseware with closed captions')
- .example('$0 -d your_download_path -h --uz', 'download and unzip handouts')
- .example('$0 -d your_download_path --cw --verbose', 'download videos from courseware and print debug info')
- .example('$0 -d your_download_path --cw --proxy http://proxy_ip_address:proxy_port_number', 'download videos from courseware via proxy tunnel')
- .example('$0 -d your_download_path --proxy http://proxy_ip_address:proxy_port_number --test', 'test proxy and download video via proxy tunnel')
- .demand('d');
+ inquirer = require('inquirer');
exports.create = function start() {
'use strict';
- process.title = 'mongo-edu';
+ process.title = pkg.name;
+
+ console.log('\n[ ' + pkg.name.toUpperCase() + ' ' + pkg.version + ' ]\n');
var argv = yargs.argv, proxyDetails = {}, lookFor = ((!argv.h)? 'Videos' : 'Handouts'), isWin = /^win/.test(process.platform), slash = (isWin) ? '\\' : '/';
@@ -57,7 +40,7 @@ exports.create = function start() {
configure(argv, function conf(err) {
if (err !== null) { throw err; }
- if (!argv.proxy) { return run(profile); }
+ if (!argv.proxy || argv.h) { return run(profile); }
proxyDetails = url.parse(argv.proxy);
@@ -65,7 +48,11 @@ exports.create = function start() {
mdbvideos.checkProxy(argv.proxy, function get(err, data) {
if (err !== null) {
- (argv.verbose) ? console.log('i'.red + ' Proxy Error: '.red + err.stack) : console.log('i'.red + ' Proxy Might By Unusable.'.red);
+ if (argv.verbose) {
+ console.log('i'.red + ' Proxy Error: '.red + err.stack);
+ } else {
+ console.log('i'.red + ' Proxy Might By Unusable.'.red);
+ }
}
if (data) { console.log('i'.magenta + ' ' + data); }