2016-02-23 00:36:23 +08:00
|
|
|
/**
|
|
|
|
* Created by tdzl2003 on 2/13/16.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const {loadSession} = require('./api');
|
|
|
|
const userCommands = require('./user').commands;
|
|
|
|
import {commands as bundleCommands} from './bundle';
|
|
|
|
|
|
|
|
function printUsage({args}) {
|
|
|
|
// const commandName = args[0];
|
|
|
|
// TODO: print usage of commandName, or print global usage.
|
|
|
|
|
|
|
|
console.log('Usage is under development now.')
|
|
|
|
console.log('Visit `https://github.com/reactnativecn/react-native-pushy` for early document.');
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
const commands = {
|
|
|
|
...userCommands,
|
|
|
|
...bundleCommands,
|
|
|
|
help: printUsage,
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.run = function () {
|
|
|
|
const argv = require('cli-arguments').parse(require('../cli.json'));
|
|
|
|
|
|
|
|
loadSession()
|
|
|
|
.then(()=>commands[argv.command](argv))
|
2016-02-23 13:17:46 +08:00
|
|
|
.catch(err=>{
|
|
|
|
setTimeout(()=>{
|
|
|
|
throw err;
|
|
|
|
});
|
|
|
|
});
|
2016-02-23 00:36:23 +08:00
|
|
|
};
|