blash/commands/man.json

65 lines
1.2 KiB
JSON
Raw Normal View History

2010-12-22 02:28:45 +01:00
{
"name" : "man",
"info" : {
"syntax" : "man <page>",
"brief" : "Display the manual page for the command 'page'",
},
"action" : function ( arg ) {
var out = '';
if ( arg == undefined || arg.length == 0 )
{
return "What manual page do you want?<br/>\n";
}
2010-12-22 02:32:47 +01:00
var cmd = shell.commands;
2010-12-22 02:28:45 +01:00
if ( arg == 'blash' )
{
var commands = new Array();
out = '<span class="brief">Type "<span class="syntax">man &lt;command&gt;</span>" for a more detailed help on these commands</span><br/><br/>';
for ( var i=0; i < cmd.length; i++ )
{
commands.push ( cmd[i].info.syntax );
}
commands.sort();
for ( var i in commands )
{
out += '<span class="syntax">' + commands[i] + '</span><br/>';
}
return out;
}
var found = false;
for ( var i=0; i < cmd.length && !found; i++ )
{
if ( arg == cmd[i].name )
{
if ( cmd[i].info.syntax.length > 0 && cmd[i].info.brief.length > 0 )
{
found = true;
out =
'<span class="syntax">' + cmd[i].info.syntax + '</span><br/><br/>' +
'<span class="brief">' + cmd[i].info.brief + '</span><br/>';
}
}
}
if ( !found )
{
return "No manual entry for " + arg + "<br/>\n";
}
return out;
},
}