var page = new WebPage();
var system = require('system');

var url = 'http://twitter.com/#!/search/javascript';
var timeout = 4000;  
var test = page.injectJs('./args.js');
console.log(test);
//argsParser();
function displayHelp () {
    console.log('Usage:');
    console.log(system.args[0] + ' \'http://twitter.com/#!/search/javascript\'');
    phantom.exit();
}

var options = {
    'commands' : {
        'url' : {
            'required': true,
            'help': 'page of url to grab'
        },
        'timeout' : {
            'required': true,
            'help': 'set timeout for loading Ajax of page to grab'
        },
        'help': {
            'help': displayHelp()
        }
    }
   
}


function argParser (options) {
    if (system.args.length === 1) {        
        options.help.help();        
    } else {
        console.log(system.args.length);
        phantom.exit();
        url = system.args[1];
        console.log(system.args[2]);
        if (system.args[2] != 'undefined') {
            timeout = system.args[2];
        }
        phantom.exit();        
    }
}

argParser(options);

page.open(url, function (status) {
    if (status === 'success') {
        getFullDom();
    } else {
       console.log('failure open page');
    }
});

function getFullDom() {
    window.setTimeout(function () {
        var results = page.evaluate(function() {
            return document.getElementsByTagName('html')[0].innerHTML
            // If jquery is loaded you can use this: 
            //return $('html').html();
        });
        console.log(results);
        phantom.exit();
    }, timeout);
}

@@ -51,17 +51,16 @@
 stem');%0A
-%0A
 var url 
@@ -130,81 +130,8 @@
 ;  %0A
-var test = page.injectJs('./args.js');%0Aconsole.log(test);%0A//argsParser();
 %0Afun
@@ -289,349 +289,8 @@
 %0A%7D%0A%0A
-var options = %7B%0A    'commands' : %7B%0A        'url' : %7B%0A            'required': true,%0A            'help': 'page of url to grab'%0A        %7D,%0A        'timeout' : %7B%0A            'required': true,%0A            'help': 'set timeout for loading Ajax of page to grab'%0A        %7D,%0A        'help': %7B%0A            'help': displayHelp()%0A        %7D%0A    %7D%0A   %0A%7D%0A%0A
 %0Afun
@@ -306,23 +306,16 @@
 Parser (
-options
 ) %7B%0A    
@@ -366,25 +366,43 @@
     
-options.help.help
+displayHelp();%0A        phantom.exit
 (); 
@@ -404,24 +404,26 @@
 t();        
+ 
+ 
 %0A    %7D else 
@@ -424,32 +424,34 @@
  else %7B%0A        
+//
 console.log(syst
@@ -471,32 +471,8 @@
 h);%0A
-        phantom.exit();%0A
     
@@ -501,45 +501,8 @@
 1%5D;%0A
-        console.log(system.args%5B2%5D);%0A
     
@@ -580,16 +580,50 @@
 rgs%5B2%5D;%0A
+            console.log(timeout);%0A
         
@@ -624,32 +624,34 @@
       %7D%0A        
+//
 phantom.exit(); 
@@ -681,15 +681,8 @@
 ser(
-options
 );%0A%0A

update grab-dom