#!/usr/bin/env node

'use strict';

var program = require('commander');
var create = require("../lib/create");
var publish = require("../lib/publish");
var util = require("../lib/src/util")

program
    .version('1.2.8');

/**
 * Publish
 * */
program
    .command('publish')
    .description('Publish a flax project to many platforms with cordova!')
    .option('-p, --plat', 'The target platform: ios/android/web/wechat/fb')
    .option('-s, --sin', 'Single all the js files to one, true/false')
    .option('-m, --min', 'Use google compile to zip all the files to one, true/false')
    .option('-o, --obs', 'Obscure the js files, true/false')
    .option('-c, --clean', 'Clean the project and publish, true/false')
    .action(function() {
        var args = util.parseArgs();
        publish(args);
    });

program.command("create")
    .description("Create a new flax project in current folder, for example: 'iflax create simpleGame'")
    .action(function() {
        var argv = process.argv.slice(3);
        var projName = argv[0];
        if (!projName) {
            throw "Pleas give iflax a project name, for example: 'iflax create simpleGame'";
        }
        create(projName);
    })

program.parse(process.argv);