Example #1
0
	// 发送消息
	function run() {
    switch(info.type) {
      case 'text':
        if (msg[0]) return send_text(msg[0]);
        return program.prompt('Text: ', send_text);
      case 'image':
        if (msg[0]) return send_image(msg[0]);
        return program.prompt('Image url: ', send_image);
      case 'location':
        if (msg[0]) return send_location(msg[0], msg[1]);
        return program.prompt('Lat: ', function(lat) {
          program.prompt('Lng: ', function(lng) {
            send_location(lat, lng);
          });
        });
      case 'event':
        if (msg[0]) return send_event(msg[0], msg[1]);
        return program.prompt('Event type: ', function(event) {
          program.prompt('Event key:', function(eventKey) {
            send_event(event, eventKey);
          });
        });
      default:
        console.error('Unsupported message type.'.red);
        process.exit();
    }
	}
Example #2
0
      adLdapSettings.discoverSettings(info.connectionDomain, function(config) {
        var detectedUrl = '';
        var detectedDN = ''
        if (config) {
          detectedUrl = config.LDAP_URL || '';
          detectedDN = config.LDAP_BASE || '';

        }

        if (console.restore) console.restore();
        
        program.prompt('Please enter your LDAP server URL [' + (detectedUrl) + ']: ', function (url) {
          ldap_url = (url && url.length>0) ? url : detectedUrl;

          program.prompt('Please enter the LDAP server base DN [' + (detectedDN) + ']: ', function (dn) {
            ldap_base = (dn && dn.length>0) ? dn : detectedDN;

            nconf.set('LDAP_BASE', ldap_base);
            nconf.set('LDAP_URL', ldap_url);
            nconf.save();

            if (console.inject) console.inject();

            cb();
          });
        });
      });
Example #3
0
 program.password('Password: '******'*', function (password) {
   program.prompt('RealName: ', function (realname) {
     CreateZncUser(user, password, realname, function () {
       process.exit(1);
     });
   });
 });
Example #4
0
	.action(function(path){
		program
			.prompt({
				username: '******',
				password: '******',
				domain: 'Localhost tunnel subdomain e.g. bunyip.pagekite.me: ',
				cmd: 'Localhost tunnel command e.g. pagekite.py or show: '
			}, function(opts) {
				var config = {
					browserstack: {
						username: opts.username,
						password: opts.password,
						timeout: 480
					},
					port: 9000,
					tunnellink: opts.domain,
					tunnel: opts.cmd + " <port> " + opts.domain
				};

				var configuration = JSON.stringify(config, null, 4),
					js = "var config = " + configuration + ";\n\nmodule.exports = config;";

				fs.writeFile((path || ""), js, 'utf8', function(err) {
					if(err) {
						return console.log(err);
					}
					console.log("Config file successfully created!");
				});

				process.stdin.destroy();
			});
	});
Example #5
0
 program.prompt('Which table # is the Child/Destination? ', Number, function(dest) { 
     if (dest >= 0 && dest < tables.length) {
      var destTable = tables[dest];
      if (destTable == sourceTable) return enterRelationsLoop();
      listColumns(destTable);
      program.prompt('Which column # refers to the Parent? ', Number, function(field) { 
         if (field >= 0 && field < columns[destTable].length) {
             var destField = columns[destTable][field];
             listColumns(sourceTable);
             program.prompt('Which column # identified this Parent object? ', Number, function(field) { 
                  if (field >= 0 && field < columns[sourceTable].length) {
                      var sourceField = columns[sourceTable][field];
                      tableRelations.push({
                          source:sourceTable,
                          target:destTable,
                          targetField:destField,
                          sourceField:sourceField
                      });   
                      if (u.indexOf(tableDependencies[destTable],sourceTable) == -1) tableDependencies[destTable].push(sourceTable);
                      if (!fieldsToCache[sourceTable]) fieldsToCache[sourceTable] = {};
                      fieldsToCache[sourceTable][sourceField] = 1;
                      if (!fieldCache[sourceTable]) fieldCache[sourceTable] = {};
                      if (!fieldCache[sourceTable][sourceField]) fieldCache[sourceTable][sourceField] = {};
                  }
                  enterRelationsLoop(); 
             });
         } else enterRelationsLoop();                   
      });
     } else enterRelationsLoop();
 })
Example #6
0
function login(options) {
  var info = {};
  var _login = function(info) {
    yuan(options).login(info, function(err) {
      console.log();
      if (err) {
        var errors = err.split('\n');
        errors.forEach(function(msg) {
          console.error('  ' + color.red(msg));
        });
      } else {
        console.log(color.green('  login success.'));
      }
    });
  };
  if (options.authkey && options.username) {
    info.username = options.username;
    info.authkey = options.authkey;
    _login(info);
    return;
  }
  commander.prompt('  username (your github account username): ', function(username) {
    info.username = username;
    commander.password('  authkey (copy from spmjs account page): ', function(authkey) {
      info.authkey = authkey;
      _login(info);
    });
  });
}
Example #7
0
function getDirectory(callback) {
  ask.prompt("Where do you want to install configs? [/etc/pigsty] ", function(target) {

    if (!target) {
      target = '/etc/pigsty';
    }

    if (fs.existsSync(target)) {
      ask.confirm("[X] Path already exists: " + target + ". Do you want us to overwrite it? [y/n] ", function(ok) {
        if (ok) {
          wrench.rmdirSyncRecursive(target);
        } else {
          console.error("[X] Unable to complete setup.");
          exit(1);
        }

        setupDirectory(target); 
      
      });
    } else {
      setupDirectory(target);
    }
  
  });
};
 t.oauth.getOAuthRequestToken(function (err, oauth_token, oauth_secret) {
   if (err) return cb(err);
   console.error('Visit ' + color.warning('https://twitter.com/oauth/authorize?oauth_token=%s'), oauth_token);
   console.error('Once you confirm authentication, you will be granted a PIN number.');
   program.prompt(color.bold('Please enter this PIN number') + ': ', function (pin) {
     t.oauth.getOAuthAccessToken(oauth_token, oauth_secret, pin, function (err, token, secret) {
       if (err) {
         if (parseInt(err.statusCode) == 401) {
           err.message = 'The PIN number you have entered is incorrect';
         }
         return cb(err);
       }
       config.data.access_token_key = token;
       config.data.access_token_secret = secret;
       try {
         config.save();
       } catch (e) {
         err = e;
       }
       if (err) return cb(err);
       t = new Twitter(config.data); // Recreate client with full OAuth data
       done();
     });
   });
 });
Example #9
0
function login(options) {
  var info = {};
  var _login = function(info) {
    yuan(options).login(info, function(err) {
      console.log();
      if (err) {
        var errors = err.split('\n');
        errors.forEach(function(msg) {
          console.error('  ' + msg);
        });
      } else {
        console.log('  login: login success.');
      }
      console.log();
    });
  };
  if (options.password && options.username) {
    info.username = options.username;
    info.password = options.password;
    _login(info);
    return;
  }
  commander.prompt('  username: '******'  password: ', function(password) {
      info.password = password;
      _login(info);
    });
  });
}
Example #10
0
    askNextQuestion: function() {
        var step = this.currentStep(),
            questionText,
            promptText;

        questionText = step.question.split( '\n' );
        questionText = [
            questionText[0].green.underline,
            questionText.slice( 1 ).join( '\n' )
        ].join( '\n' );

        console.log( '' );
        console.log( questionText );

        if( step.answers.length === 0 ) {
            process.exit();
        } else {
            promptText = '';
            for( var i = 0; i < step.answers.length; i++ ) {
                promptText += ( i > 0 ? ', ' : '' ) +
                    step.answers[ i ] +
                    ' [' + ( i + 1 ) + ']';
            }
            promptText += ': ';

            program.prompt(
                promptText,
                this.handleAnswer.bind( this )
            );
        }
    },
Example #11
0
  .action(function() {
    console.log()
    console.log('info: '.cyan, 'Beginning admin user setup')
    var user = {};
    user.role = 'Admin'
    program.prompt('Name: ', function(name) {
      user.name = name
      program.prompt('Email: ', function(email) {
        user.email = email
        program.password('Password: '******'*', function(p) {
          user.password = p
          var seeder = new (require('./scripts/seed'))(user)
          seeder.save(function(err) {
            if (err) {
              console.log('error:'.red, err)
              process.exit(1)
            } else {
              console.log('info: '.cyan, 'Successfully created admin user')
              process.exit()
            }
          })
        })
      })
    })

  })
Example #12
0
    program.prompt('Type recipient id:', function(recipient) {
        recipient = recipient.trim();
        if (!recipient) {
            return prompt();
        }

        program.prompt('Message:', function(data) {
            data = data.trim();
            if (!data) {
                return prompt();
            }

            console.time('delivery time');

            simpleioServer.message()
                .recipient(recipient)
                .data(data)
                .send(function(err, delivered) {
                    if (err) return console.log('Error', err);

                    console.log('Delivered', delivered);
                    console.timeEnd('delivery time');
                    prompt();

                });
        });
    });
Example #13
0
/*
 * 发布与服务端的命令交互
 */
function requestIntractive(info, loading){
    loading.end();
    switch(info.type){
        case 'SUCCESS':
            console.log('[ok]'.info, info.msg);
            process.exit();
            break;

        case 'ERROR':
            console.log('[error]'.error, info.msg);
            process.exit();
            break;

        case 'WARN':
            console.log('[warn]'.warn, info.msg);
            process.exit();
            break;

        case 'CONFIRM':
            program.prompt(info.msg + ' ', function(input){
                if(input.toUpperCase() == 'Y'){
                    http.get(_requestUrl+'&confirm=y', handlerResponse).on('error', requestErrorHanlder);
                }
            });
            break;
    }
}
Example #14
0
function create_user(options) {
  options = options || {};

   var success = options.success || function() {
     terminal.exit('\nUser created!\n\n');
   }, error = options.error || function(err) {
     terminal.abort('Failed to created user', err);
   };

  program.prompt('username: '******'password: '******'*', function(password) {
      program.password('confirm password: '******'*', function(password2) {
        if(password != password2) {
          terminal.abort('Password do not match, bailing out.');
        }
        program.prompt('email: ', function(email) {
          var body = {username: username, password: password, email: email}
            , db = require('captain-core/lib/db');

          db.users.create(body, function(err) {
            if(err) {
              error(err);
            } else {
              success();
            }
          });

        });
      });
    });
  });
}
Example #15
0
    program.prompt('Access Key: ', function (key) {
      config.access_key = key || config.access_key;

      program.prompt('Secret Key: ', function (key) {
        config.secret_key = key || config.secret_key;


        console.log();
        program.confirm('Use HTTPS protocol? (yes or no) ', function (ok) {
          console.log();
          if (ok) {
            config.use_https = 'True';
          } else {
            config.use_https = 'False';
          }

          console.log();
          console.log('New settings:');
          console.log('Hostname: %s', config.host_base);          
          console.log('Access Key: %s', config.access_key);
          console.log('Secret Key: %s', config.secret_key);
          console.log('Use HTTPS protocol: %s', config.use_https);

          console.log();
          program.confirm('Save settings? (yes or no) ', function (ok) {
            console.log();
            if (ok) {
              self.write(config);
            }
            cb();
          });
        });
      });
    });
// Get Github credentials
function getCredentials() {

	var dfd = new _.Deferred();

	program.prompt("Github Username: "******"Github Password: "******"*", function( pass ) {
			var timeout;
			password = pass;
			process.stdin.pause();

			github.authenticate({
				type: "basic",
				username: username,
				password: password
			});

			process.stdout.write("Building CanJS...")
			stealTimeout = setInterval(function() {
				process.stdout.write(".")
			}, 1000 )
			dfd.resolve();
		})

	});

	return dfd.promise();
}
 function collectDescription( next ){
     program.prompt("Description: ", function( description ){
         sketchplate.createTemplate( config, {
             name: name,
             description: description
         }, next);
     });
 }
Example #18
0
    function (next) {
      if (username) return next()

      commander.prompt('Username: ', function (input) {
        process.stdin.pause() // work-around for #133
        username = input
        next()
      })
    }
Example #19
0
  return function () {
    program.prompt((msg ? msg : prompt + (def ? ' [' + def + ']' : '')) + ': ', function (value) {
      if (value) {
        pkg[prompt] = value;
      }

      methods.shift()();
    });
  };
Example #20
0
    function (cb) {
      provisioningTicket = nconf.get('PROVISIONING_TICKET');

      if(provisioningTicket) return cb();

      program.prompt('Please enter the ticket number: ', function (pt) {
        provisioningTicket = pt;
        cb();
      });
    },
Example #21
0
  'prompt': function(next, context) {
    program.prompt('What’s your name? ', function(name) {
      if ('' === name) {
        next('prompt');
      } else {
        context.name = name;

        next('display');
      }
    });
  },
 function collectName( next ){
     //if a name wasnt provided, ask for it
     if( name === undefined ){
         program.prompt("Name: ", function( _name ){
             name = _name;
             next();
         });
     } else {
         next();
     }
 },
Example #23
0
 get_site_name: function(config, callback) {
   program.prompt('Site name: ', function(newSiteName){
     var is_valid_site_name = validation.valid_site_name(newSiteName);
     if (is_valid_site_name.isValid) {
       config.name = newSiteName;
       callback(null, config);
     } else {
       console.log(is_valid_site_name.message);
       prompts.get_site_name(config, callback);
     } 
   });
 },
Example #24
0
function configUser(callback){
  program.prompt('Input you taobao login user name: ', function(name){
    name = util.format("_nk_=%s;", escapeIt(name));
    var headers = config.getJSON('./config.json', __dirname);
    headers['headers']['Cookie'] = name;
    config.joyrc('upload', headers);
    console.log('config success');
    console.log(JSON.stringify(headers, null, 2));
    process.stdin.destroy();
    callback && callback.call && callback();
  });
}
Example #25
0
        program.prompt('port: ', function(port) {
            conf.push('-p '+ port);

            program.prompt('vhost: ', function(vhost) {
                conf.push('-n '+ vhost);
                process.stdin.destory();

                fs.writeFileSync('.locally', conf.join('\n'), 'utf8');

                loadConfiguration();
            });
        });
Example #26
0
 (function input() {
   var inputPrompt = prompts.shift()
   if(!inputPrompt) {
     process.stdin.pause()
     return cb(addends)
   }
   
   program.prompt(inputPrompt, Number, function(number){
     addends.push(number)
     input()  
   })
      
 })()
Example #27
0
	function show_summary(env, after) {
		console.log(s('\nOption Summary', colors.header));
		console.log(s('MySQL host ', colors.text) + s(c.host, colors.param));
		console.log(s('MySQL user ', colors.text) + s(c.user, colors.param));
		console.log(s('MySQL pass ', colors.text) + s('(hidden)', ['red']));
		console.log(s('Database to process ', colors.text) + s(c.database, colors.param));
		console.log(s('Output directory ', colors.text) + s(c.output, colors.param));
		if (c.all)
			console.log(s('Processing all tables', colors.text));
		else
			console.log(s('Prompting for tables', colors.text));
		c.prompt(s('\nPress enter to continue, or ctrl+c to cancel', colors.header)+' ', after);
	},
program.prompt('Please enter component id: ', function (aId) {
    var id = aId.trim();

    program.prompt('Please enter component title: ', function (aTitle) {

        var title = aTitle.trim();

        program.prompt('Please enter component description: ', function (aDesc) {

            var description = aDesc;

            console.log("About to create component '%s'".info, id);
            console.log("Component's title: %s".info, title);
            console.log("Component's description: %s".info, description);

            if(!fs.existsSync(LIB_FOLDER)) {

                fs.mkdirSync(LIB_FOLDER);

                console.log("Folder '%s' created".warn, LIB_FOLDER);
            }


            var componentFolder = LIB_FOLDER + id;
            var componentPath = componentFolder + "/component.json";

            if (fs.existsSync(componentFolder)) {
                console.log("Folder '%s' already exist".warn, componentFolder);

                return destroy();
            }

            fs.mkdirSync(componentFolder);

            console.log("Folder %s created".info, componentFolder);

            var componentJson = {
                "title":title,
                "description":description
            };

            fs.writeFileSync(componentPath, JSON.stringify(componentJson, null, '\t'), "utf8");

            console.log("File %s created".info, componentPath);

            destroy();
        });
    });
});
Example #29
0
        program.prompt('Please enter your LDAP server URL [' + (detectedUrl) + ']: ', function (url) {
          ldap_url = (url && url.length>0) ? url : detectedUrl;

          program.prompt('Please enter the LDAP server base DN [' + (detectedDN) + ']: ', function (dn) {
            ldap_base = (dn && dn.length>0) ? dn : detectedDN;

            nconf.set('LDAP_BASE', ldap_base);
            nconf.set('LDAP_URL', ldap_url);
            nconf.save();

            if (console.inject) console.inject();

            cb();
          });
        });
Example #30
0
module.exports = function(options) {
  if (options.username && options.password) {
    login(options);
    return;
  }
  console.log();
  commander.prompt('  do you have an account? (Y/n) ', function(have) {
    console.log();
    if (have.charAt(0).toLowerCase() === 'n') {
      register(options);
    } else {
      login(options);
    }
  });
};