package org.zanata.maven;

import org.zanata.client.commands.pull.PullCommand;
import org.zanata.client.commands.pull.PullOptions;

/**
 * Pulls translated text from Zanata.
 * 
 * @goal pull
 * @requiresProject true
 * @requiresOnline true
 * @author Sean Flanigan <sflaniga@redhat.com>
 */
public class PullMojo extends PushPullMojo<PullOptions> implements PullOptions
{

   /**
    * Export source-language text from Zanata to local files, overwriting or
    * erasing existing files (DANGER!)
    * 
    * @parameter expression="${zanata.pullSrc}"
    */
   private boolean pullSrc;

   /**
    * Whether to create skeleton entries for strings/files which have not been translated yet
    * @parameter expression="${zanata.createSkeletons}"
    */
   private boolean createSkeletons;

   public PullMojo() throws Exception
   {
      super();
   }

   public PullCommand initCommand()
   {
      return new PullCommand(this);
   }

   @Override
   public boolean getPullSrc()
   {
      return pullSrc;
   }

   @Override
   public boolean getCreateSkeletons()
   {
      return createSkeletons;
   }

}

@@ -123,16 +123,160 @@
 Options;
+%0Aimport org.zanata.client.config.LocaleList;%0Aimport org.zanata.client.config.LocaleMapping;%0Aimport org.zanata.client.exceptions.ConfigException;
 %0A%0A/**%0A *
@@ -933,313 +933,2174 @@
 %0A   
-public PullMojo() throws Exception%0A   %7B%0A      super();%0A   %7D%0A%0A   public PullCommand initCommand()%0A   %7B%0A      return new PullCommand(this);%0A   %7D%0A%0A   @Override%0A   public boolean getPullSrc()%0A   %7B%0A      return pullSrc;%0A   %7D%0A%0A   @Override%0A   public boolean getCreateSkeletons()%0A   %7B%0A      return createSkeleton
+/**%0A    * Locales to pull from the server.%0A    * By default all locales in zanata.xml will be pulled.%0A    * Usage: -Dzanata.locales=locale1,locale2,locale3%0A    *%0A    * @parameter expression=%22$%7Bzanata.locales%7D%22%0A    */%0A   private String%5B%5D locales;%0A%0A   // Cached copy of the effective locales to avoid calculating it more than once%0A   private LocaleList effectiveLocales;%0A%0A%0A   public PullMojo() throws Exception%0A   %7B%0A      super();%0A   %7D%0A%0A   public PullCommand initCommand()%0A   %7B%0A      return new PullCommand(this);%0A   %7D%0A%0A   @Override%0A   public boolean getPullSrc()%0A   %7B%0A      return pullSrc;%0A   %7D%0A%0A   @Override%0A   public boolean getCreateSkeletons()%0A   %7B%0A      return createSkeletons;%0A   %7D%0A%0A   /**%0A    * Override the default %7B@link org.zanata.maven.ConfigurableProjectMojo#getLocaleMapList()%7D method as the push%0A    * command can have locales specified via command line.%0A    *%0A    * @return The locale map list taking into account the global locales in zanata.xml as well as the command line%0A    * argument ones.%0A    */%0A   @Override%0A   public LocaleList getLocaleMapList()%0A   %7B%0A      if( effectiveLocales == null )%0A      %7B%0A         if(locales != null && locales.length %3E 0)%0A         %7B%0A            // filter the locales that are specified in both the global config and the parameter list%0A            effectiveLocales = new LocaleList();%0A%0A            for( String locale : locales )%0A            %7B%0A               boolean foundLocale = false;%0A               for(LocaleMapping lm : super.getLocaleMapList())%0A               %7B%0A                  if( lm.getLocale().equals(locale) %7C%7C%0A                        (lm.getMapFrom() != null && lm.getMapFrom().equals( locale )) )%0A                  %7B%0A                     effectiveLocales.add(lm);%0A                     foundLocale = true;%0A                     break;%0A                  %7D%0A               %7D%0A%0A               if(!foundLocale)%0A               %7B%0A                  throw new ConfigException(%22Specified locale '%22 + locale + %22' was not found in zanata.xml!%22 );%0A               %7D%0A            %7D%0A         %7D%0A         else%0A         %7B%0A            effectiveLocales = super.getLocaleMapList();%0A         %7D%0A      %7D%0A%0A      return effectiveLocale
 s;%0A 

Add zanata.locales option to pull command.