Methods Summary |
---|
private void | aliasCreationFailed(java.lang.String name, java.lang.Exception e)
final String value = getAliasMgr().resolveAlias( name );
if ( value != null )
{
printError( "Failed to create alias: " + name + "(already exists with value " + value + ")" );
printError( "If you want to change it, delete it first." );
}
else if ( ExceptionUtil.getRootCause( e ) instanceof IllegalArgumentException )
{
printError( "Illegal alias name: " + name );
}
else
{
printError( "Failed to create alias: " + name );
}
|
void | executeInternal()
final String [] pairs = getOperands();
final boolean replace = getBoolean( "replace", Boolean.FALSE).booleanValue();
for( int i = 0; i < pairs.length; ++i )
{
final String pair = pairs[ i ];
final int separatorIndex = pair.indexOf( '=" );
if ( separatorIndex < 0 )
{
printError( "Alias request must be of form name=value: " + pair );
continue;
}
final String name = pair.substring( 0,separatorIndex);
final String value = pair.substring( separatorIndex + 1, pair.length() );
try
{
if ( replace )
{
getAliasMgr().deleteAlias( name );
}
getAliasMgr().createAlias( name, value );
printError( "Created alias: " + name );
}
catch( Exception e )
{
aliasCreationFailed( name, e);
}
}
|
public static java.lang.String[] | getNames()
return( new String [] { "create-alias", "ca" } );
|
ArgHelper.OptionsInfo | getOptionInfo()
return( new ArgHelperOptionsInfo( OPTIONS_INFO ) );
|
public java.lang.String | getUsage()
return( CmdStrings.CREATE_ALIAS_HELP.toString() );
|