"use strict";

var readlineSync = require( '@fsteam/readline-sync' );

var util = require( './lib/util' ).obj;
var bUtil = require( './lib/util/build.util' ).obj;
var build = require( './lib/build' );
var release = require( './lib/release' );
var server = require( './lib/server' );

exports.init = function() {
    var project_name;

    if ( arguments.length > 1 ) {
        project_name = arguments[ 1 ];
    } else {
        project_name = bUtil.getName( "请输入您要创建的项目名：" );
    }
    if ( !project_name ) {
        return util.log( "创建项目结束！！" );
    }

    build.build_project( project_name, true );
    build.copy_project_conf( project_name, true );

    if ( readlineSync.question( "是否继续创建项目的频道？（y/n）" ) === "y" ) {
        build.build_module( project_name, true );
    }

    server.run();
};
exports.buildCmd = function() {
    build.init.apply( this, arguments );
};
exports.releaseCmd = function() {
    release.init.apply( this, arguments );
};
exports.dev = function( project_name ) {

};