man.groovy

groovy/scripts/commands/player/man.groovy · 883 B

From the archive groovymud-0.3.4-alpha-bin.tar.gz

Download the archive   « Back to the archive contents

package commands.player

import groovy.util.slurpersupport.NoChildren

def root = new XmlSlurper().parse(new File("$scriptSpace/commands/player/man-text.xml"))

def manRecord = root.entry.find{ it.@name == args[0] }
def io = source.getTerminalOutput()
if(manRecord.size() > 0){
	if(manRecord.@gpath != ""){
		io.writeln(manRecord.gpath)
	}else{
		def desc = manRecord.description.text().replaceAll('\t', '').replaceAll('  ', '')
		io.writeln(desc)
		if(manRecord.syntax.size() > 0){
			io.writeln("Syntax:");
			io.writeln(manRecord.syntax.text().replaceAll('\t', ''))
		}
		if(manRecord.example.size() > 0){
			io.writeln("Example:");
			io.writeln(manRecord.example.text().replaceAll('\t', ''))
		}
		if(manRecord.seealso.size() > 0){
			io.writeln("See also:")
			io.writeln(manRecord.seealso.text().replaceAll('\t', ''))
		}
	}
}else{
	io.writeln("No man entry for ${args[0]}")
}

Site Stats

Snippets: 1791
Codebases: 571