Aliaspublic 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. |
Constructors Summary |
---|
public Alias()
super(new String []{ "alias"} );
getOptions().addOption(new Option("d", "delete", false, "delete the specified alias"));
|
Methods Summary |
---|
private void | addAlias(org.gudy.azureus2.ui.console.ConsoleInput ci, java.lang.String aliasName, java.util.List 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 void | deleteAlias(org.gudy.azureus2.ui.console.ConsoleInput ci, java.lang.String aliasName)
// 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 void | execute(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.String | getCommandDescriptions()
return "alias [-d] [aliasname] [arguments...]\tadd/modify/delete aliases. use with no argument to show existing aliases";
| private void | printAlias(org.gudy.azureus2.ui.console.ConsoleInput ci, java.lang.String 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 void | printAliases(org.gudy.azureus2.ui.console.ConsoleInput ci)prints out a list of all the aliases
for (Iterator iter = ci.aliases.keySet().iterator(); iter.hasNext();) {
String aliasName = (String)iter.next();
printAlias(ci, aliasName);
}
|
|