All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.onetwo.common.commandline.HelpCommand Maven / Gradle / Ivy

There is a newer version: 4.7.2
Show newest version
package org.onetwo.common.commandline;

import java.util.Map;


public class HelpCommand extends AbstractCommand{
	
	public static final String NAME = "help";
	
	public HelpCommand(){
		super("help", "");
	}

	@Override
	public void doExecute(CmdContext context) {
		CommandManager mng = this.getCommandManager();
		StringBuilder help = new StringBuilder();
		Map commands = mng.getCommands();
		if(commands==null || commands.isEmpty()){
			help.append("no commands!");
			System.out.println(help.toString());
			return ;
		}
		for(Map.Entry cmdEntry : commands.entrySet()){
			if(cmdEntry.getValue()==this)
				continue;
			help.append(cmdEntry.getKey()).append(" : ").append(cmdEntry.getValue().helpDoc()).append("\n");
		}
		System.out.println(help);
		this.doc = help.toString();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy