Examples of CommandLineParser


Examples of bdsup2sub.cli.CommandLineParser

        processOptions();
        execute();
    }

    private void parseOptions(String[] args) {
        options = new CommandLineParser();
        try {
            options.parse(args);
        } catch (ParseException e) {
            fatalError(e.getMessage());
            options.printHelp();
View Full Code Here

Examples of ch.entwine.weblounge.tools.util.CommandLineParser

  /*
   * @see TestCase#setUp()
   */
  protected void setUp() throws Exception {
    super.setUp();
    parser = new CommandLineParser();
    parser.defineCommand("unmerge");
    parser.defineCommand(new String[] {"u", "update"});
    parser.defineCommand(new String[] {"v", "verbose"});
    parser.defineCommand(new String[] {"p", "pretend"});
    parser.defineOption("m");
View Full Code Here

Examples of com.facebook.presto.hive.shaded.org.apache.commons.cli.CommandLineParser

  }

  public static void main(String[] args) {
    HiveMetaTool metaTool = new HiveMetaTool();
    metaTool.init();
    CommandLineParser parser = new GnuParser();
    CommandLine line = null;

    try {
      try {
        line = parser.parse(metaTool.cmdLineOptions, args);
      } catch (ParseException e) {
        System.err.println("HiveMetaTool:Parsing failed.  Reason: " + e.getLocalizedMessage());
        printAndExit(metaTool);
      }
View Full Code Here

Examples of com.vmware.vim25.mo.util.CommandLineParser

public class VMClone
{
   public static void main(String[] args) throws Exception
   {
     CommandLineParser clp = new CommandLineParser(constructOptions(), args);
    
     String urlStr = clp.get_option("url");
     String username = clp.get_option("username");
     String password = clp.get_option("password");
     String cloneName = clp.get_option("CloneName");
     String vmPath = clp.get_option("vmPath");
     String datacenterName= clp.get_option("DatacenterName");

     try
     {
       ServiceInstance si = new ServiceInstance(new URL(urlStr), username, password, true);
       VirtualMachine vm = (VirtualMachine) si.getSearchIndex().findByInventoryPath(vmPath);
View Full Code Here

Examples of com.zaranux.client.org.apache.commons.cli.CommandLineParser

  }
  @Override
  protected final void main(String[] args) {
      try
      {
        CommandLineParser parser = new PosixParser();
        cmd = parser.parse( options, args,true);
        execute( new AsyncCallback<Boolean>()
      {
        public void onSuccess(Boolean b) // ture, got user's credential, false user cancelled, ...
        {
          Log.debug("ending command " + this.getClass().getName());
View Full Code Here

Examples of games.stendhal.common.CommandlineParser

           cmd = script + " " + cmd;
        }
      }

      // use the same routine as in the client to parse quoted arguments
      final CommandlineParser parser = new CommandlineParser(cmd);
      final ErrorDrain errors = new ErrorBuffer();

      final List<String> args = parser.readAllParameters(errors);

      new GameEvent(player.getName(), "script", script, mode, args.toString()).raise();

      // execute script
      script = script.trim();
View Full Code Here

Examples of joshua.util.CommandLineParser

   *
   * @param args Command line arguments
   */
  public static void main(String[] args) {

    CommandLineParser commandLine = new CommandLineParser();
   
    Option<String> source_file = commandLine.addStringOption('s',"source-text","SOURCE_FILENAME","name of file containing source language corpus");
    //Option<String> source_file_encoding = commandLine.addStringOption("source-encoding","SOURCE_ENCODING","ISO-8859-1","source language file encoding");
    Option<String> source_file_encoding = commandLine.addStringOption("source-encoding","SOURCE_ENCODING","UTF-8","source language file encoding");
    Option<Boolean> source_file_gz = commandLine.addBooleanOption("source-text-gzipped",false,"is the source text gzipped");
   
    Option<String> target_file = commandLine.addStringOption('t',"target-text","TARGET_FILENAME","name of file containing target language corpus");
    //Option<String> target_file_encoding = commandLine.addStringOption("target-encoding","TARGET_ENCODING","ISO-8859-1","target language file encoding");
    Option<String> target_file_encoding = commandLine.addStringOption("target-encoding","TARGET_ENCODING","UTF-8","target language file encoding");
    Option<Boolean> target_file_gz = commandLine.addBooleanOption("target-text-gzipped",false,"is the target text gzipped");
   
    Option<String> alignment_file = commandLine.addStringOption('a',"alignment","ALIGNMENT_FILENAME","name of file containing word alignments for the sentences in the corpus");
    Option<Boolean> alignment_file_gz = commandLine.addBooleanOption("alignment-file-gzipped",false,"is the alignment file gzipped");

    Option<Integer> num_lines = commandLine.addIntegerOption('l',"lines","LINE_COUNT","number of aligned sentences in the corpus");
   
    Option<String> output_file = commandLine.addStringOption('o',"output","OUTPUT_FILENAME","file where aligned word pairs will be written");
    Option<String> output_file_encoding = commandLine.addStringOption("output-encoding","OUTPUT_ENCODING","UTF-8","output file encoding");
    Option<Boolean> output_file_gz = commandLine.addBooleanOption("output-text-gzipped",false,"should the output file be gzipped");
   
    commandLine.parse(args);
   
   
    try {
     
      // Set System.out and System.err to use the provided character encoding
      try {
        System.setOut(new PrintStream(System.out, true, commandLine.getValue(source_file_encoding)));
        System.setErr(new PrintStream(System.err, true, commandLine.getValue(source_file_encoding)));
      } catch (UnsupportedEncodingException e1) {
        System.err.println(commandLine.getValue(source_file_encoding) + " is not a valid encoding; using system default encoding for System.out and System.err.");
      } catch (SecurityException e2) {
        System.err.println("Security manager is configured to disallow changes to System.out or System.err; using system default encoding.");
      }
     
      // The number of lines to read
      int number_of_lines = commandLine.getValue(num_lines);

      // Set up the source text for reading
      Scanner source_text;
      if (commandLine.getValue(source_file).endsWith(".gz") || commandLine.getValue(source_file_gz)) {
        source_text = new Scanner(new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(commandLine.getValue(source_file))),commandLine.getValue(source_file_encoding))));
      } else {
        source_text = new Scanner( new File(commandLine.getValue(source_file)), commandLine.getValue(source_file_encoding));
      }
     
      // Set up the target text for reading
      Scanner target_text;
      if (commandLine.getValue(target_file).endsWith(".gz") || commandLine.getValue(target_file_gz)) {
        target_text = new Scanner(new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(commandLine.getValue(target_file))),commandLine.getValue(target_file_encoding))));
      } else {
        target_text = new Scanner( new File(commandLine.getValue(target_file)), commandLine.getValue(target_file_encoding));
      }
     
      // Set up the alignment file for reading
      Scanner alignments;
      if (commandLine.getValue(alignment_file).endsWith(".gz") || commandLine.getValue(alignment_file_gz)) {
        alignments = new Scanner(new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(commandLine.getValue(alignment_file))))));
      } else {
        alignments = new Scanner( new File(commandLine.getValue(alignment_file)));
      }
     
     
      // Set up the output file for writing
      Writer outputFile;
      if (commandLine.getValue(output_file).endsWith(".gz") || commandLine.getValue(output_file_gz)) {
        outputFile = new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(commandLine.getValue(output_file))),commandLine.getValue(output_file_encoding));
      } else {
        outputFile = new OutputStreamWriter(new FileOutputStream(commandLine.getValue(output_file)),commandLine.getValue(output_file_encoding));
      }
     
      try {
        extract(number_of_lines, source_text, target_text, alignments, outputFile);
      } catch (NoSuchElementException e) {
        System.err.println("There are more than " + number_of_lines + " lines of input. Please determine the actual number of lines of input, and re-run with the appropriate command line flag.");
        commandLine.printUsage();
        System.exit(-1);
      }

    } catch (FileNotFoundException e) {
      e.printStackTrace();
View Full Code Here

Examples of no.priv.garshol.duke.utils.CommandLineParser

   */
  public String[] init(String[] argv, int min, int max,
                       Collection<CommandLineParser.Option> options)
    throws IOException, SAXException {
    // parse command line
    parser = new CommandLineParser();
    parser.setMinimumArguments(min);
    parser.setMaximumArguments(max);
    parser.registerOption(new CommandLineParser.BooleanOption("reindex", 'I'));
    if (options != null)
      for (CommandLineParser.Option option : options)
View Full Code Here

Examples of org.apache.commons.cli.CommandLineParser

 
  /**
   * take the args and try and create a command line object
   */
  public void execute(String commandName, ConsoleInput console, List arguments) {
    CommandLineParser parser = getParser();
   
    try
    {
      String []args = new String[arguments.size()];
      int i = 0;
      for (Iterator iter = arguments.iterator(); iter.hasNext();) {
        String arg = (String) iter.next();
        args[i++] = arg;
      }
      CommandLine line = parser.parse(getOptions(), args);
      execute( commandName, console, line );
    } catch (ParseException e)
    {
      console.out.println(">> Invalid arguments: " + e.getMessage());     
//      printHelp(commandName, console.out);
View Full Code Here

Examples of org.apache.commons.cli.CommandLineParser

  private static CommandLine parseCommands(String[] args, boolean constart) {
   
    if (args==null)
      return null;
   
    CommandLineParser parser = new PosixParser();
    Options options = new Options();
    options.addOption("h", "help", false, "Show this help.");
    OptionBuilder.withLongOpt("exec");
    OptionBuilder.hasArg();
    OptionBuilder.withArgName("file");
    OptionBuilder.withDescription("Execute script file. The file should end with 'logout', otherwise the parser thread doesn't stop.");
    options.addOption( OptionBuilder.create('e'));
   
    OptionBuilder.withLongOpt("command");
    OptionBuilder.hasArg();
    OptionBuilder.withArgName("command");
    OptionBuilder.withDescription("Execute single script command. Try '-c help' for help on commands.");
    options.addOption(OptionBuilder.create('c'));
   
    OptionBuilder.withLongOpt("ui");
    OptionBuilder.withDescription("Run <uis>. ',' separated list of user interfaces to run. The first one given will respond to requests without determinable source UI (e.g. further torrents added via command line).");
    OptionBuilder.withArgName("uis");
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create('u'));
   
    CommandLine commands = null;
    try {
      commands = parser.parse(options, args, true);
    } catch( ParseException exp ) {
      Logger.getLogger("azureus2").error("Parsing failed.  Reason: " + exp.getMessage(), exp);
      if (constart)
        System.exit(2);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.