//$(document).append("sup")//"<h3>DDG answers provided by <a href='//duckduckgo.com'>DuckDuckGo</a><img src='//duckduckgo.com/favicon.ico'></img></h3>");

op = optparse3;
parser = new op.Parser(
    "ddg [QUERY] OPTIONS",
    {
        QUERY: ["string to search with", op.filters.position("query", op.coercers.nonOption)],
        OPTIONS: op.filters.options([
            op.options.set("html", "H", "view HTML formated results"),
            op.options.set("help", "h", "view this help page"),
        ]),
    },
    {
        html: false,
        help: false,
    }
)

process.ddg = function(args, io){
    try{
        opts = parser.parse(args);
    }catch(e){
        io.errln(e.message);
        throw new WrongUsage(e.message);
    }
    if(opts.help){
        io.writeln(parser.doc);
        throw new Success();
    }
    function ddg(query, callback){
        var url = "http://api.duckduckgo.com/?format=json&t=TermJS&q="+encodeURI(query);
        $.ajax({
            url: url,
            dataType: "jsonp",
            success: function(reply){
                console.log(reply);
                var R = reply.RelatedTopics
                for(var i = 0; i < R.length; i++){
                    if(R[i].Result)
                        io.writeln(R[i].Result);
                    /*else{
                        for(var j = 0; j < R[i].Topics.length)
                    }*/
                }
                io.writeln()//JSON.stringify(reply, undefined, 4));
                callback();
            },
            error: function(){
                console.log(arguments);
                io.errln("Query for '"+query+"' failed");
                io.kill(new Failure("IOError"));
            },
        })
    }
    if(opts.query){
        ddg(opts.query, function(results){
            io.kill(new Success());
        })
    }
    else{
        function read(line){
            ddg(line, function(){
                io.readln(read);
            });
        }
        io.readln(read);
    }
    io.errln("DDG answers provided by <a href='//duckduckgo.com'>DuckDuckGo</a><img src='//duckduckgo.com/favicon.ico'></img>")
}

@@ -1292,14 +1292,27 @@
     
-/*
 else
+ if(R%5Bi%5D.Topic)
 %7B%0A  
@@ -1374,33 +1374,125 @@
 ngth
-)%0A                    %7D*/
+; j++)%7B%0A                            io.writeln(R%5Bi%5D.Topic%5Bj%5D.Result);%0A                        %7D%0A                    %7D
 %0A   

Update ddg.js