FileDocCategorySizeDatePackage
Alias.javaAPI DocAzureus 3.0.3.44200Wed Jan 05 04:23:48 GMT 2005org.gudy.azureus2.ui.console.commands

Alias

public class Alias extends OptionsConsoleCommand
the alias command will add/remove/modify aliases to the CLI input reader. aliases will be expanded and take priority over standard commands.
author
pauld

Fields Summary
Constructors Summary
public Alias()

param
_commandNames

		super(new String []{ "alias"} );
		getOptions().addOption(new Option("d", "delete", false, "delete the specified alias"));
	
Methods Summary
private voidaddAlias(org.gudy.azureus2.ui.console.ConsoleInput ci, java.lang.String aliasName, java.util.List argList)

param
object
param
argList

//		ci.out.println("adding alias: " + aliasName);
		StringBuffer aliasText = new StringBuffer();
		for (Iterator iter = argList.iterator(); iter.hasNext();) {
			String arg = (String) iter.next();
			if( arg.indexOf(" ") != -1 )
				aliasText.append("\"").append(arg).append("\"");
			else
				aliasText.append(arg);
			aliasText.append(" ");
		}
		ci.aliases.put(aliasName, aliasText.toString());
		ci.saveAliases();
		printAlias(ci, aliasName);
	
private voiddeleteAlias(org.gudy.azureus2.ui.console.ConsoleInput ci, java.lang.String aliasName)

param
object

//		ci.out.println("removing alias: " + aliasName);
		if( ci.aliases.remove(aliasName) == null )
		{
			ci.out.println("> Error: Alias '" + aliasName + "' does not exist");
		}
		else
		{
			ci.out.println("> Alias: '" + aliasName + "' deleted");
			ci.saveAliases();
		}
	
public voidexecute(java.lang.String commandName, org.gudy.azureus2.ui.console.ConsoleInput console, org.apache.commons.cli.CommandLine commandLine)

		
		List args = commandLine.getArgList();
		if( args.isEmpty() )
		{
			if( commandLine.hasOption('d") )
				console.out.println(commandName + " --delete requires the name of an alias to remove");
			else
				printAliases(console);
			return;
		}
		if( commandLine.hasOption('d") )
			deleteAlias(console, (String) args.get(0));
		else
		{
			String aliasName = (String) args.remove(0);
			if( args.isEmpty() )
			{
				printAlias(console, aliasName);
			}
			else
				addAlias( console, aliasName, args );
		}
	
public java.lang.StringgetCommandDescriptions()

		return "alias [-d] [aliasname] [arguments...]\tadd/modify/delete aliases. use with no argument to show existing aliases";
	
private voidprintAlias(org.gudy.azureus2.ui.console.ConsoleInput ci, java.lang.String aliasName)

param
aliasName

		String aliasText = (String) ci.aliases.get(aliasName);
		if( aliasText == null )
		{
			ci.out.println("> Error: Alias '" + aliasName + "' does not exist");
		}
		else
		{
			ci.out.println("> " + aliasName + "=" + aliasText);
		}
	
private voidprintAliases(org.gudy.azureus2.ui.console.ConsoleInput ci)
prints out a list of all the aliases

param
out

		for (Iterator iter = ci.aliases.keySet().iterator(); iter.hasNext();) {
			String aliasName = (String)iter.next();
			printAlias(ci, aliasName);
		}