module.exports = function () {

    var packageinfo = require('../package.json'),
        name = packageinfo.name,
        version = packageinfo.version || '--.--.--';

    var argv = require('argv')
        .version(version)
        .info("Usage: " + name + " SPECFILES [Options]\n\n" +
              "SPECFILES:  spec files or directories.\n\n" +
              "Options:")
        .option([
            {   name:           'match',
                short:          'm',
                type:           'string',
                description:    'mather RegEx.',
                example:        "'" + name + " --reporter-type=console' or '" + name + " -r junit'"
            },
            {   name:           'helpers',
                type:           'csv,path',
                description:    'Spec files or directories to run.',
                example:        "'" + name + " --specs=file1,file2,..'"
            },
            {   name:           'output',
                short:          'o',
                type:           'path',
                description:    'Output file',
                example:        "'" + name + " --outout=file' or '" + name + " -o file'"
            },
            {   name:           'codegs',
                type:           'path',
                description:    'execute Codegs and output to specified file.',
                example:        "'" + name + " --outout=file' or '" + name + " -o file'"
            }
        ])
        .run();

    // all options should be fully resolved path.
    var config = {
        specs:      argv.targets,
        match:      argv.options.match      || null,
        helpers:    argv.options.helpers    || null,
        output:     argv.options.output     || null,
        codegs:     argv.options.codegs     || null
    };

    // Create and configure Application.
    var rajahApp = require('./rajahApp').create();
    var error;

    error = rajahApp.addConfig(config);
    _check(error);

    error = rajahApp.run();
    _check(error);
};

function _check(error) {
    if (error !== null) {
        if (error.substr(0, 6) === 'Error:') {
            console.error(error);
            console.log('');
            process.exit(1);
        } else {
            console.log(error);
        }
    }
}


if (module.parent === null) {
    module.exports();
}

@@ -308,17 +308,17 @@
 FILES:  
-s
+S
 pec file
@@ -386,16 +386,212 @@
 ption(%5B%0A
+            %7B   name:           'color',%0A                type:           'string'%0A            %7D,%0A            %7B   name:           'noColor',%0A                type:           'string'%0A            %7D,%0A
         
@@ -738,16 +738,17 @@
     'mat
+c
 her RegE
@@ -748,16 +748,53 @@
 er RegEx
+p. always added i(ignore case) option
 .',%0A    
@@ -842,29 +842,25 @@
 %22 --
-reporter-type=console
+match=-Spec%5C%5C.js$
 ' or
@@ -879,15 +879,21 @@
  %22 -
-r junit
+s -Spec%5C%5C.js$
 '%22%0A 
@@ -910,32 +910,34 @@
  %7D,%0A            
+//
 %7B   name:       
@@ -941,23 +941,26 @@
        '
-helpers
+reportType
 ',%0A     
@@ -962,32 +962,35 @@
             
+//
     
-type
+short
 :           
@@ -992,18 +992,10 @@
     
- 'csv,path
+'r
 ',%0A 
@@ -1009,62 +1009,37 @@
     
+//
     
-description:    'Spec files or directories to run.
+type:           'string
 ',%0A 
@@ -1053,67 +1053,67 @@
     
+//
     
-example:        %22'%22 + name + %22 --specs=file1,file2,..'%22
+description:    'reporter type. %5B console %7C junit %5D',
 %0A   
@@ -1113,32 +1113,34 @@
 %5D',%0A            
+//
 %7D,%0A            %7B
@@ -1289,16 +1289,46 @@
 put file
+path result will be stored in.
 ',%0A     
@@ -1370,36 +1370,40 @@
 me + %22 --outout=
-file
+FILEPATH
 ' or '%22 + name +
@@ -1400,36 +1400,40 @@
 %22 + name + %22 -o 
-file
+FILEPATH
 '%22%0A            %7D
@@ -1501,36 +1501,38 @@
 ype:           '
-path
+string
 ',%0A             
@@ -1594,24 +1594,258 @@
 ied file.',%0A
+            %7D,%0A            %7B   name:           'package',%0A                short:          'p',%0A                type:           'path',%0A                description:    'filepath which package file should be handed to codegs command.',%0A
             
@@ -1885,19 +1885,21 @@
 %22 --
-outout=file
+path=FILEPATH
 ' or
@@ -1918,14 +1918,18 @@
  %22 -
-o file
+p FILEPATH
 '%22%0A 
@@ -2054,24 +2054,28 @@
 specs:      
+    
 argv.targets
@@ -2088,24 +2088,36 @@
     
-match:     
+showColor:      (typeof
  arg
-v
+c
 .opt
@@ -2125,26 +2125,103 @@
 ons.
-match      %7C%7C null
+color !== 'undefined') %7C%7C%0A                        (typeof argc.options.noColor === 'undefined')
 ,%0A  
@@ -2230,20 +2230,24 @@
     
-helpers:
+match:   
     
+   
 argv
@@ -2259,15 +2259,15 @@
 ons.
-helpers
+match  
     
@@ -2291,24 +2291,28 @@
 output:     
+    
 argv.options
@@ -2348,24 +2348,35 @@
 codegs:     
+    typeof 
 argv.options
@@ -2383,19 +2383,80 @@
 .codegs 
-   
+!== 'undefined',%0A        packagefile:    argv.options%5B'package'%5D
  %7C%7C null

add command line options.