<commit_before>package net.openl10n.flies.client;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import net.openl10n.flies.client.commands.AppAbortStrategy;
import net.openl10n.flies.client.commands.ArgsUtil;
import net.openl10n.flies.client.commands.BasicOptions;
import net.openl10n.flies.client.commands.FliesCommand;
import net.openl10n.flies.client.commands.ListRemoteCommand;
import net.openl10n.flies.client.commands.PutProjectCommand;
import net.openl10n.flies.client.commands.PutUserCommand;
import net.openl10n.flies.client.commands.PutVersionCommand;
import net.openl10n.flies.client.commands.SystemExitStrategy;

import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;

public class FliesClient implements BasicOptions
{
   private String command;
   private boolean debug;
   private boolean errors;
   private boolean help;
   private boolean quiet;
   private boolean version;

   @Argument(index = 1, multiValued = true)
   private final List<String> arguments = new ArrayList<String>();
   private final CmdLineParser parser = new CmdLineParser(this);
   private final LinkedHashMap<String, Class<? extends FliesCommand>> commandMap = createLinkedHashMap();
   private final AppAbortStrategy abortStrategy;
   private final PrintStream out;
   private final PrintStream err;

   public static void main(String[] args)
   {
      FliesClient tool = new FliesClient(new SystemExitStrategy(), System.out, System.err);
      tool.processArgs(args);
   }

   private static <K, V> LinkedHashMap<K, V> createLinkedHashMap()
   {
      return new LinkedHashMap<K, V>();
   }

   public FliesClient(AppAbortStrategy strategy, PrintStream out, PrintStream err)
   {
      this.abortStrategy = strategy;
      this.out = out;
      this.err = err;
      // getCommandMap().put("listlocal", ListLocalCommand.class);
      getCommandMap().put("listremote", ListRemoteCommand.class);
      // getCommandMap().put("publish", PublishCommand.class);
      // getCommandMap().put("retrieve", RetrieveCommand.class);
      getCommandMap().put("putproject", PutProjectCommand.class);
      getCommandMap().put("putuser", PutUserCommand.class);
      getCommandMap().put("putversion", PutVersionCommand.class);
   }

   public String getCommandName()
   {
      return "flies";
   }

   public String getCommandDescription()
   {
      return "Flies command-line client";
   }

   public LinkedHashMap<String, Class<? extends FliesCommand>> getCommandMap()
   {
      return commandMap;
   }

   protected void processArgs(String... args)
   {
      try
      {
         parser.parseArgument(args);
      }
      catch (CmdLineException e)
      {
         if (!getHelp() && args.length != 0)
         {
            err.println(e.getMessage());
            printHelp(err);
            abortStrategy.abort();
         }
      }
      if (getHelp() && command == null)<commit_msg>workaround for broken test<commit_after>package net.openl10n.flies.client;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import net.openl10n.flies.client.commands.AppAbortStrategy;
import net.openl10n.flies.client.commands.ArgsUtil;
import net.openl10n.flies.client.commands.BasicOptions;
import net.openl10n.flies.client.commands.FliesCommand;
import net.openl10n.flies.client.commands.ListRemoteCommand;
import net.openl10n.flies.client.commands.PutProjectCommand;
import net.openl10n.flies.client.commands.PutUserCommand;
import net.openl10n.flies.client.commands.PutVersionCommand;
import net.openl10n.flies.client.commands.SystemExitStrategy;

import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;

public class FliesClient implements BasicOptions
{
   private String command;
   private boolean debug;
   private boolean errors;
   private boolean help;
   private boolean quiet;
   private boolean version;

   @Argument(index = 1, multiValued = true)
   private final List<String> arguments = new ArrayList<String>();
   private final CmdLineParser parser = new CmdLineParser(this);
   private final LinkedHashMap<String, Class<? extends FliesCommand>> commandMap = createLinkedHashMap();
   private final AppAbortStrategy abortStrategy;
   private final PrintStream out;
   private final PrintStream err;

   public static void main(String[] args)
   {
      FliesClient tool = new FliesClient(new SystemExitStrategy(), System.out, System.err);
      tool.processArgs(args);
   }

   private static <K, V> LinkedHashMap<K, V> createLinkedHashMap()
   {
      return new LinkedHashMap<K, V>();
   }

   public FliesClient(AppAbortStrategy strategy, PrintStream out, PrintStream err)
   {
      this.abortStrategy = strategy;
      this.out = out;
      this.err = err;
      // getCommandMap().put("listlocal", ListLocalCommand.class);
      getCommandMap().put("listremote", ListRemoteCommand.class);
      // getCommandMap().put("publish", PublishCommand.class);
      // getCommandMap().put("retrieve", RetrieveCommand.class);
      getCommandMap().put("putproject", PutProjectCommand.class);
      getCommandMap().put("putuser", PutUserCommand.class);
      getCommandMap().put("putversion", PutVersionCommand.class);
   }

   public String getCommandName()
   {
      return "flies";
   }

   public String getCommandDescription()
   {
      return "Flies command-line client";
   }

   public LinkedHashMap<String, Class<? extends FliesCommand>> getCommandMap()
   {
      return commandMap;
   }

   protected void processArgs(String... args)
   {
      // FIXME remove this workaround for failing test (client used in multiple
      // tests)
      arguments.clear();
      try
      {
         parser.parseArgument(args);
      }
      catch (CmdLineException e)
      {
         if (!getHelp() && args.length != 0)
         {
            err.println(e.getMessage());
            printHelp(err);
            abortStrategy.abort();
         }
      }
      if (getHelp() && command == null)
{'fraction_non_alphanumeric': 0.10782104924364339, 'fraction_numerical': 0.008368200836820083, 'mean_word_length': 3.665915915915916, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2148874', 'n_tokens_mistral': 1846, 'n_tokens_neox': 1806, 'n_words': 387}