#!/usr/bin/env node
'use strict';

/*
 * Dependencies.
 */

var spawn,
    pack;

spawn = require('win-fork');
pack = require('./package.json');

/*
 * Resolve.
 */

var mdast,
    toc;

mdast = require.resolve('mdast/cli.js');
toc = require.resolve('./index.js');

/*
 * Arguments.
 */

var argv;

argv = process.argv.slice(2);

/*
 * Command.
 */

var command;

command = Object.keys(pack.bin)[0];

/*
 * Program.
 */

if (argv[0] === '--version' || argv[0] === '-v') {
    /*
     * Version.
     */

    console.log(pack.version);
} else if (argv[0] === '--help' || argv[0] === '-h') {
    /*
     * Help.
     */

    console.log([
        '',
        'Usage: ' + command + ' [mdast options]',
        '',
        pack.description,
        '',
        'Options:',
        '',
        '  -h, --help            output usage information',
        '  -v, --version         output version number',
        '',
        'A wrapper around `mdast --use ' + command + '`',
        '',
        'Help for mdast:',
        '',
        '  https://github.com/wooorm/mdast',
        '',
        'Usage:',
        '',
        '# Pass `Readme.md` through ' + command,
        '$ ' + command + ' Readme.md -o Readme.md',
        '',
        '# Pass stdin through ' + command + ', with mdast options, ' +
            'and write to stdout',
        '$ cat Docs.md | ' + command + ' --option setext > Docs-new.md',
        '',
        '# Use other plugins',
        '$ npm install mdast-usage',
        '$ ' + command + ' --use mdast-usage Readme.md'
    ].join('\n  ') + '\n');
} else {
    /*
     * Spawn.
     */

    var proc;

    proc = spawn(mdast, ['--use', toc].concat(argv), {
        'stdio': 'inherit'
    });

    /*
     * Exit.
     */

    proc.on('exit', function (code) {
        process.exit(code);
    });
}

@@ -61,26 +61,8 @@
 var 
-spawn,%0A    pack;%0A%0A
 spaw
@@ -86,16 +86,20 @@
 fork');%0A
+var 
 pack = r
@@ -153,25 +153,8 @@
 var 
-mdast,%0A    toc;%0A%0A
 mdas
@@ -190,16 +190,20 @@
 i.js');%0A
+var 
 toc = re
@@ -262,15 +262,8 @@
 var 
-argv;%0A%0A
 argv
@@ -317,18 +317,8 @@
 var 
-command;%0A%0A
 comm
@@ -425,40 +425,8 @@
 ) %7B%0A
-    /*%0A     * Version.%0A     */%0A%0A
     
@@ -511,37 +511,8 @@
 ) %7B%0A
-    /*%0A     * Help.%0A     */%0A%0A
     
@@ -1467,52 +1467,11 @@
     
-/*%0A     * Spawn.%0A     */%0A%0A    var proc;%0A%0A   
+var
  pro

Refactor code style in `cli.js`