diff options
author | przemyslawpluta <przemekpluta@hotmail.com> | 2014-09-28 18:36:08 +0100 |
---|---|---|
committer | przemyslawpluta <przemekpluta@hotmail.com> | 2014-09-28 18:36:08 +0100 |
commit | 75245d62fdd7230ac3bdb634f26ad0da8826f61f (patch) | |
tree | d9156924b6d80fdbf024652ae4184fd5fd37bcfe /lib | |
parent | 50b4cf93765ad4a74672baa12f8d59772356aad9 (diff) | |
download | mongo-edu-75245d62fdd7230ac3bdb634f26ad0da8826f61f.zip |
cleanup
Diffstat (limited to 'lib')
-rw-r--r-- | lib/initialize.js | 10 | ||||
-rw-r--r-- | lib/prompts.js | 44 | ||||
-rw-r--r-- | lib/validate.js | 14 |
3 files changed, 49 insertions, 19 deletions
diff --git a/lib/initialize.js b/lib/initialize.js index cbb2d99..a3c6834 100644 --- a/lib/initialize.js +++ b/lib/initialize.js @@ -8,6 +8,7 @@ var mdbvideos = require('./login'), videoHandler = require('./videos'), + prompts = require('./prompts'), colors = require('colors'), inquirer = require('inquirer'); @@ -19,14 +20,7 @@ module.exports = function run(profile, argv) { inquirer.prompt(profile, function prompt(answers) { - var list = [{ type: 'list', name: 'url', message: '', choices: [] }], classes = list, - - check = [{ type: 'checkbox', message: '', name: 'videos', choices: [], - validate: function validate(answer) { - if ( answer.length < 1 ) { return 'You must choose at least one option.'; } - return true; - } - }]; + var list = prompts.list, classes = list, check = prompts.check; mdbvideos.init(answers, argv, function get(err, data) { if (err !== null) { throw err; } diff --git a/lib/prompts.js b/lib/prompts.js new file mode 100644 index 0000000..0af81e8 --- /dev/null +++ b/lib/prompts.js @@ -0,0 +1,44 @@ +/* + * mongo-edu + * + * Copyright (c) 2014 Przemyslaw Pluta + * Licensed under the MIT license. + * https://github.com/przemyslawpluta/mongo-edu/blob/master/LICENSE + */ + +module.exports = (function build() { + + 'use strict'; + + return { + savePrompt: [{ type: 'input', name: 'save', message: 'Missing [ --save ] Preset Name', default: '', validate: function(value) { + if (value !== '') { return true; } + return 'Please enter [ --save ] preset name'; + }}], + + loadPreset: function loadPreset(data) { + return [{ type: 'list', name: 'preset', message: 'Select Preset To Load:', choices: data}]; + }, + + list: [{ type: 'list', name: 'url', message: '', choices: [] }], + + check: [{ type: 'checkbox', message: '', name: 'videos', choices: [], + validate: function validate(answer) { + if ( answer.length < 1 ) { return 'You must choose at least one option.'; } + return true; + } + }], + + profile: [ + { type: 'input', name: 'user', message: 'MongoDB Uni User Name', default: '', validate: function(value) { + if (value !== '') { return true; } + return 'Please enter your MongoDB Uni user name - email address'; + }}, + { type: 'password', message: 'MongoDB Uni Password', name: 'password', validate: function(value) { + if (value !== '') { return true; } + return 'Please enter your MongoDB Uni password'; + }} + ] + }; + +}()); diff --git a/lib/validate.js b/lib/validate.js index c6909d6..d0b5e9e 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -6,22 +6,14 @@ * https://github.com/przemyslawpluta/mongo-edu/blob/master/LICENSE */ -var mkdirp = require('mkdirp'); +var mkdirp = require('mkdirp'), + prompts = require('./prompts'); module.exports.init = function init(opt, callback) { 'use strict'; - var profile = [ - { type: 'input', name: 'user', message: 'MongoDB Uni User Name', default: '', validate: function(value) { - if (value !== '') { return true; } - return 'Please enter your MongoDB Uni user name - email address'; - }}, - { type: 'password', message: 'MongoDB Uni Password', name: 'password', validate: function(value) { - if (value !== '') { return true; } - return 'Please enter your MongoDB Uni password'; - }} - ]; + var profile = prompts.profile; if (opt.u !== '') { profile[0].default = opt.u; } |