'use strict';

var init = require('./init'),
    Path = require('path'),
    program = require('commander');

module.exports = function app() {
    program.on('--help', function() {
        console.log('Usage:\n');
        console.log('$ site.js --watch build\n');
        console.log('$ site.js --port 3210 serve\n');
        console.log('');
    });


    program.option('-t, --template <template>', 'specify a global template [index.swig]', String);
    program.option('-p, --template-path <path>', 'template path [./template]', String);
    program.option('-o, --output <name>', 'name of the output file [index.js]', String);

    program
        .command('init')
        .description('initializing website')
        .action(function(source, target) {
            var config = {
                source: source,
                target: target,
                output: program.output || 'index.js',
                templatePath: Path.resolve(program.templatePath || './template'),
                template: program.template || '/index.swig'
            };

            init(config, process.exit);
        });

    program.parse(process.argv);
};

@@ -133,24 +133,25 @@
 ion app() %7B%0A
+%0A
     program.
@@ -153,563 +153,106 @@
 gram
-.on('--help', function() %7B%0A        console.log('Usage:%5Cn');%0A        console.log('$ site.js --watch build%5Cn');%0A        console.log('$ site.js --port 3210 serve%5Cn');%0A        console.log('');%0A    %7D);%0A%0A%0A    program.option('-t, --template %3Ctemplate%3E', 'specify a global template %5Bindex.swig%5D', String);%0A    program.option('-p, --template-path %3Cpath%3E', 'template path %5B./template%5D', String);%0A    program.option('-o, --output %3Cname%3E', 'name of the output file %5Bindex.js%5D', String);%0A%0A    program%0A        .command('init')%0A        .description('initializing website
+%0A        .command('init %5Bsource%5D %5Btarget%5D')%0A        .description('Create new static site generator
 ')%0A 
@@ -293,16 +293,18 @@
 rget) %7B%0A
+%0A%0A
         
@@ -352,16 +352,29 @@
 : source
+ %7C%7C 'content'
 ,%0A      
@@ -397,16 +397,28 @@
 : target
+ %7C%7C 'public'
 ,%0A      
@@ -691,27 +691,378 @@
 gram
-.parse(process.argv
+%0A        .version('0.0.1')%0A        .option('-t, --template %3Ctemplate%3E', 'specify a global template %5Bindex.swig%5D', String)%0A        .option('-p, --template-path %3Cpath%3E', 'template path %5B./template%5D', String)%0A        .option('-o, --output %3Cname%3E', 'name of the output file %5Bindex.js%5D', String)%0A        .parse(process.argv);%0A%0A    if (program.args.length === 0) program.help(
 );%0A%7D

improve cli