import org.tizen.common.verrari.Template;
import org.tizen.common.verrari.TemplateContext;
import org.tizen.common.verrari.TemplateException;
-import org.tizen.common.verrari.realm.StandardRealm;
+import org.tizen.common.verrari.realm.CommonRealm;
import org.tizen.common.verrari.storage.FileStorage;
import org.tizen.common.verrari.template.TemplateConstants;
}
cache.put( name, template );
template.template( models, storage );
- final String[] dependencies = StandardRealm.separate( template.getAttribute( TemplateConstants.ATTR_DEPENDENCY ) );
+ final String[] dependencies = CommonRealm.separate( template.getAttribute( TemplateConstants.ATTR_DEPENDENCY ) );
if ( null == dependencies )
{
continue;
import java.io.IOException;
import java.util.Collection;
+import java.util.Iterator;
+import java.util.TreeSet;
import org.tizen.common.core.command.ExecutionContext;
import org.tizen.common.verrari.AttributeContainer;
implements CommandWithParameter
{
- @Override
- public void process(
+ protected void
+ search(
+ final Realm realm,
final ExecutionContext context,
final String[] args
) throws IOException
{
- if ( null == args || 0 == args.length )
- {
- context.getPrompter().error( "A keyword required." );
- return ;
- }
- final Realm realm = (Realm) context.getValue( PluginConstants.REALM );
-
if ( !( realm instanceof SearchableRealm ) )
{
context.getPrompter().error( "Search unsupported realm." );
context.getPrompter().notify( "No template with '" + keyword + "'." );
return ;
}
+
+ TreeSet<String> sortTree = new TreeSet<String>();
for ( final AttributeContainer template : templates )
{
final StringBuilder buffer = new StringBuilder();
final String name = template.getAttribute( TemplateConstants.ATTR_NAME );
final String desc = template.getAttribute( TemplateConstants.ATTR_DESCRIPTION );
+ final String version = template.getAttribute( TemplateConstants.ATTR_VERSION );
+
buffer.append( name );
+ if ( !isEmpty( version ) )
+ {
+ buffer.append( " ( " );
+ buffer.append( version );
+ buffer.append( " ) " );
+ }
+
buffer.append( " - " );
if ( isEmpty( desc ) )
{
{
buffer.append( desc );
}
-
- context.getPrompter().notify( buffer.toString() + "." );
+
+ sortTree.add( buffer.toString() );
+ }
+
+ // search result notify
+ Iterator<String> iter = sortTree.iterator();
+ while ( iter.hasNext() ) {
+ context.getPrompter().notify( iter.next() + "." );
}
}
+ /* (non-Javadoc)
+ * @see org.tizen.cli.command.CommandWithParameter#process(org.tizen.common.core.command.ExecutionContext, java.lang.String[])
+ */
+ @Override
+ public void process(
+ final ExecutionContext context,
+ final String[] args
+ ) throws IOException
+ {
+ if ( null == args || 0 == args.length )
+ {
+ context.getPrompter().error( "A keyword required." );
+ return ;
+ }
+ final Realm realm = (Realm) context.getValue( PluginConstants.REALM );
+ search( realm, context, args );
+ }
}