Java 类org.apache.commons.cli2.OptionException 实例源码

项目:jnrpe    文件:JNRPEServer.java   
/**
 * Parses the command line.
 * 
 * @param vsArgs
 *            The command line
 * @return The parsed command line
 */
private static CommandLine parseCommandLine(final String[] vsArgs) {
    try {
        Group opts = configureCommandLine();
        // configure a HelpFormatter
        HelpFormatter hf = new HelpFormatter();

        // configure a parser
        Parser p = new Parser();
        p.setGroup(opts);
        p.setHelpFormatter(hf);
        // p.setHelpTrigger("--help");
        return p.parse(vsArgs);
    } catch (OptionException oe) {
        printUsage(oe);
    } catch (Exception e) {
        e.printStackTrace();
        // Should never happen...
    }
    return null;
}
项目:HBase-High-Performance-Cookbook    文件:InputDriver.java   
public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
  DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
  ArgumentBuilder abuilder = new ArgumentBuilder();
  GroupBuilder gbuilder = new GroupBuilder();

  Option inputOpt = DefaultOptionCreator.inputOption().withRequired(false).create();
  Option outputOpt = DefaultOptionCreator.outputOption().withRequired(false).create();
  Option vectorOpt = obuilder.withLongName("vector").withRequired(false).withArgument(
    abuilder.withName("v").withMinimum(1).withMaximum(1).create()).withDescription(
    "The vector implementation to use.").withShortName("v").create();

  Option helpOpt = DefaultOptionCreator.helpOption();

  Group group = gbuilder.withName("Options").withOption(inputOpt).withOption(outputOpt).withOption(
    vectorOpt).withOption(helpOpt).create();

  try {
    Parser parser = new Parser();
    parser.setGroup(group);
    CommandLine cmdLine = parser.parse(args);
    if (cmdLine.hasOption(helpOpt)) {
      CommandLineUtil.printHelp(group);
      return;
    }

    Path input = new Path(cmdLine.getValue(inputOpt, "testdata").toString());
    Path output = new Path(cmdLine.getValue(outputOpt, "output").toString());
    String vectorClassName = cmdLine.getValue(vectorOpt,
       "org.apache.mahout.math.RandomAccessSparseVector").toString();
    //runJob(input, output, vectorClassName);
  } catch (OptionException e) {
    InputDriver.log.error("Exception parsing command line: ", e);
    CommandLineUtil.printHelp(group);
  }
}
项目:Chi-FRBCS-BigDataCS    文件:CommandLineUtil.java   
public static void printHelpWithGenericOptions(Group group, OptionException oe) throws IOException {
  new GenericOptionsParser(new Configuration(), new org.apache.commons.cli.Options(), new String[0]);
  PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charsets.UTF_8), true);
  HelpFormatter formatter = new HelpFormatter();
  formatter.setGroup(group);
  formatter.setPrintWriter(pw);
  formatter.setException(oe);
  formatter.print();
}
项目:Chi-FRBCS-BigData-Ave    文件:CommandLineUtil.java   
public static void printHelpWithGenericOptions(Group group, OptionException oe) throws IOException {
  new GenericOptionsParser(new Configuration(), new org.apache.commons.cli.Options(), new String[0]);
  PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charsets.UTF_8), true);
  HelpFormatter formatter = new HelpFormatter();
  formatter.setGroup(group);
  formatter.setPrintWriter(pw);
  formatter.setException(oe);
  formatter.print();
}
项目:Chi-FRBCS-BigData-Max    文件:CommandLineUtil.java   
public static void printHelpWithGenericOptions(Group group, OptionException oe) throws IOException {
  new GenericOptionsParser(new Configuration(), new org.apache.commons.cli.Options(), new String[0]);
  PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charsets.UTF_8), true);
  HelpFormatter formatter = new HelpFormatter();
  formatter.setGroup(group);
  formatter.setPrintWriter(pw);
  formatter.setException(oe);
  formatter.print();
}
项目:Apache-Mahout-cookbook    文件:App.java   
public static void main( String[] args ) throws IOException, TasteException, OptionException
{
    CreateCsvRatingsFile();


    // create data source (model) - from the csv file
    File ratingsFile = new File(outputFile);
    DataModel model = new FileDataModel(ratingsFile);

    // create a simple recommender on our data
    CachingRecommender cachingRecommender = new CachingRecommender(new SlopeOneRecommender(model));

    // for all users
    for (LongPrimitiveIterator it = model.getUserIDs(); it.hasNext();){
        long userId = it.nextLong();

        // get the recommendations for the user
        List<RecommendedItem> recommendations = cachingRecommender.recommend(userId, 10);

        // if empty write something
        if (recommendations.size() == 0){
            System.out.print("User ");
            System.out.print(userId);
            System.out.println(": no recommendations");
        }

        // print the list of recommendations for each
        for (RecommendedItem recommendedItem : recommendations) {
            System.out.print("User ");
            System.out.print(userId);
            System.out.print(": ");
            System.out.println(recommendedItem);
        }
    }
}
项目:tgm.sew.4ahit.roboterfabrik.Simulation    文件:TestMyCommandLine.java   
/**
 * Testet den Konstruktor.
 * Normalfall(alle verpflichtenden Optionen vorhanden mit gueltigen Werten der Argumente)
 */
@Test
public void testMyCommandLine_1() {
    String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/", 
            "--lieferanten", "100", "--monteure", "100", "--laufzeit", "10000"};
    MyCommandLine cli;
    try {
        assertNotNull(cli = new MyCommandLine(args));
    } catch (OptionException e) {
        cli = null;
    }
}
项目:tgm.sew.4ahit.roboterfabrik.Simulation    文件:TestMyCommandLine.java   
/**
 * Testet den Konstruktor.
 * Normalfall(alle moeglichen Optionen vorhanden mit gueltigen Werten der Argumente)
 */
@Test
public void testMyCommandLine_2() {
    String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/", 
            "--lieferanten", "100", "--monteure", "100", "--laufzeit", "10000", "--lagermitarbeiter", "100"};
    MyCommandLine cli;
    try {
        assertNotNull(cli = new MyCommandLine(args));
    } catch (OptionException e) {
        cli = null;
    }
}
项目:tgm.sew.4ahit.roboterfabrik.Simulation    文件:TestMyCommandLine.java   
/**
 * Testet den Konstruktor.
 * Fehlerfall(alle moeglichen Optionen vorhanden, mit ungueltigen Werten der Argumente(bei --lieferant))
 */
@Test(expected=IllegalArgumentException.class)
public void testMyCommandLine_3() {
    String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/", 
            "--lieferanten", "0", "--monteure", "100", "--laufzeit", "10000", "--lagermitarbeiter", "100"};
    MyCommandLine cli;
    try {
        assertNotNull(cli = new MyCommandLine(args));
    } catch (OptionException e) {
        throw new IllegalArgumentException();
    }
}
项目:tgm.sew.4ahit.roboterfabrik.Simulation    文件:TestMyCommandLine.java   
/**
 * Testet den Konstruktor.
 * Fehlerfall(alle moeglichen Optionen vorhanden, mit ungueltigen Werten der Argumente(bei --monteur))
 */
@Test(expected=IllegalArgumentException.class)
public void testMyCommandLine_4() {
    String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/", 
            "--lieferanten", "10", "--monteure", "0", "--laufzeit", "10000", "--lagermitarbeiter", "100"};
    MyCommandLine cli;
    try {
        assertNotNull(cli = new MyCommandLine(args));
    } catch (OptionException e) {
        throw new IllegalArgumentException();
    }
}
项目:tgm.sew.4ahit.roboterfabrik.Simulation    文件:TestMyCommandLine.java   
/**
 * Testet den Konstruktor.
 * Fehlerfall(alle moeglichen Optionen vorhanden, mit ungueltigen Werten der Argumente(bei --laufzeit))
 */
@Test(expected=IllegalArgumentException.class)
public void testMyCommandLine_5() {
    String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/", 
            "--lieferanten", "10", "--monteure", "10", "--laufzeit", "100", "--lagermitarbeiter", "100"};
    MyCommandLine cli;
    try {
        assertNotNull(cli = new MyCommandLine(args));
    } catch (OptionException e) {
        throw new IllegalArgumentException();
    }
}
项目:tgm.sew.4ahit.roboterfabrik.Simulation    文件:TestMyCommandLine.java   
/**
 * Testet den Konstruktor.
 * Fehlerfall(alle moeglichen Optionen vorhanden, mit ungueltigen Werten der Argumente(bei --lagermitarbeiter))
 */
@Test(expected=IllegalArgumentException.class)
public void testMyCommandLine_6() {
    String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/", 
            "--lieferanten", "10", "--monteure", "10", "--laufzeit", "1000", "--lagermitarbeiter", "0"};
    MyCommandLine cli;
    try {
        assertNotNull(cli = new MyCommandLine(args));
    } catch (OptionException e) {
        throw new IllegalArgumentException();
    }
}
项目:tgm.sew.4ahit.roboterfabrik.Simulation    文件:TestMyCommandLine.java   
/**
 * Testet den Konstruktor.
 * Fehlerfall(alle moeglichen Optionen fehlen)
 */
@Test(expected=IllegalArgumentException.class)
public void testMyCommandLine_7() {
    String[] args = {};
    MyCommandLine cli;
    try {
        assertNotNull(cli = new MyCommandLine(args));
    } catch (OptionException e) {
        throw new IllegalArgumentException();
    }
}
项目:tgm.sew.4ahit.roboterfabrik.Simulation    文件:TestMyCommandLine.java   
/**
 * Testet den Konstruktor.
 * Fehlerfall(alle moeglichen Optionen vorhanden, mit ungueltigen Werten der Argumente(bei --lieferant))
 */
@Test
public void testMyCommandLine_8() {
    String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/", 
            "--lieferanten", "blala", "--monteure", "100", "--laufzeit", "10000", "--lagermitarbeiter", "100"};
    MyCommandLine cli;
    try {
        assertNotNull(cli = new MyCommandLine(args));
    } catch (OptionException e) {
        throw new IllegalArgumentException();
    }
}
项目:tgm.sew.4ahit.roboterfabrik.Simulation    文件:TestMyCommandLine.java   
/**
 * Testet den Konstruktor.
 * Fehlerfall(alle moeglichen Optionen vorhanden, mit ungueltigen Werten der Argumente(bei --monteur))
 */
@Test
public void testMyCommandLine_9() {
    String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/", 
            "--lieferanten", "10", "--monteure", "blala", "--laufzeit", "10000", "--lagermitarbeiter", "100"};
    MyCommandLine cli;
    try {
        assertNotNull(cli = new MyCommandLine(args));
    } catch (OptionException e) {
        throw new IllegalArgumentException();
    }
}
项目:tgm.sew.4ahit.roboterfabrik.Simulation    文件:TestMyCommandLine.java   
/**
 * Testet den Konstruktor.
 * Fehlerfall(alle moeglichen Optionen vorhanden, mit ungueltigen Werten der Argumente(bei --laufzeit))
 */
@Test
public void testMyCommandLine_10() {
    String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/", 
            "--lieferanten", "10", "--monteure", "10", "--laufzeit", "blala", "--lagermitarbeiter", "100"};
    MyCommandLine cli;
    try {
        assertNotNull(cli = new MyCommandLine(args));
    } catch (OptionException e) {
        throw new IllegalArgumentException();
    }
}
项目:tgm.sew.4ahit.roboterfabrik.Simulation    文件:TestMyCommandLine.java   
/**
 * Testet den Konstruktor.
 * Fehlerfall(alle moeglichen Optionen vorhanden, mit ungueltigen Werten der Argumente(bei --lagermitarbeiter))
 */
@Test
public void testMyCommandLine_11() {
    String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/", 
            "--lieferanten", "10", "--monteure", "10", "--laufzeit", "1000", "--lagermitarbeiter", "blalaa"};
    MyCommandLine cli;
    try {
        assertNotNull(cli = new MyCommandLine(args));
    } catch (OptionException e) {
        throw new IllegalArgumentException();
    }
}
项目:tgm.sew.4ahit.roboterfabrik.Simulation    文件:TestMyCommandLine.java   
/**
 * Testet die getLagerVerzeichnis-Methode
 */
@Test
public void testGetLagerVerzeichnis() {
    String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/", 
            "--lieferanten", "100", "--monteure", "100", "--laufzeit", "10000"};
    MyCommandLine cli;
    try {
        assertNotNull(cli = new MyCommandLine(args));
    } catch (OptionException e) {
        cli = null;
    }
    assertEquals("roboterfabrik/lager/", cli.getLagerVerzeichnis());
}
项目:tgm.sew.4ahit.roboterfabrik.Simulation    文件:TestMyCommandLine.java   
/**
 * Testet die getLogVerzeichnis-Methode
 */
@Test
public void testGetLogVerzeichnis() {
    String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/", 
            "--lieferanten", "100", "--monteure", "100", "--laufzeit", "10000"};
    MyCommandLine cli;
    try {
        assertNotNull(cli = new MyCommandLine(args));
    } catch (OptionException e) {
        cli = null;
    }
    assertEquals("roboterfabrik/logs/", cli.getLogVerzeichnis());
}
项目:tgm.sew.4ahit.roboterfabrik.Simulation    文件:TestMyCommandLine.java   
/**
 * Testet die getLieferantenAnzahl-Methode
 */
@Test
public void testGetLieferantenAnzahl() {
    String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/", 
            "--lieferanten", "101", "--monteure", "102", "--laufzeit", "10003"};
    MyCommandLine cli;
    try {
        assertNotNull(cli = new MyCommandLine(args));
    } catch (OptionException e) {
        cli = null;
    }
    assertEquals(101, cli.getLieferantenAnzahl());
}
项目:tgm.sew.4ahit.roboterfabrik.Simulation    文件:TestMyCommandLine.java   
/**
 * Testet die getMonteurAnzahl-Methode
 */
@Test
public void testGetMonteurAnzahl() {
    String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/", 
            "--lieferanten", "101", "--monteure", "102", "--laufzeit", "10003"};
    MyCommandLine cli;
    try {
        assertNotNull(cli = new MyCommandLine(args));
    } catch (OptionException e) {
        cli = null;
    }
    assertEquals(102, cli.getMonteurAnzahl());
}
项目:tgm.sew.4ahit.roboterfabrik.Simulation    文件:TestMyCommandLine.java   
/**
 * Testet die getLagerMitarbeiterAnzahl-Methode
 */
@Test
public void testGetLagerMitarbeiterAnzahl() {
    String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/", 
            "--lieferanten", "101", "--monteure", "102", "--laufzeit", "10003", "--lagermitarbeiter", "104"};
    MyCommandLine cli;
    try {
        assertNotNull(cli = new MyCommandLine(args));
    } catch (OptionException e) {
        cli = null;
    }
    assertEquals(104, cli.getLagerMitarbeiterAnzahl());
}
项目:tgm.sew.4ahit.roboterfabrik.Simulation    文件:TestMyCommandLine.java   
/**
 * Testet die getLaufzeit-Methode
 */
@Test
public void testGetLaufzeit() {
    String[] args = {"--lager", "roboterfabrik/lager/", "--logs", "roboterfabrik/logs/", 
            "--lieferanten", "101", "--monteure", "102", "--laufzeit", "10003", "--lagermitarbeiter", "104"};
    MyCommandLine cli;
    try {
        assertNotNull(cli = new MyCommandLine(args));
    } catch (OptionException e) {
        cli = null;
    }
    assertEquals(10003, cli.getLaufzeit());
}
项目:Chi-FRBCS-BigDataCS    文件:TestModel.java   
@Override
 public int run(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
 // TODO Auto-generated method stub
   DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
   ArgumentBuilder abuilder = new ArgumentBuilder();
   GroupBuilder gbuilder = new GroupBuilder();

   Option inputOpt = DefaultOptionCreator.inputOption().create();

   Option datasetOpt = obuilder.withLongName("dataset").withShortName("ds").withRequired(true).withArgument(
      abuilder.withName("dataset").withMinimum(1).withMaximum(1).create()).withDescription("Dataset path")
        .create();

   Option modelOpt = obuilder.withLongName("model").withShortName("m").withRequired(true).withArgument(
        abuilder.withName("path").withMinimum(1).withMaximum(1).create()).
        withDescription("Path to the Model").create();

Option outputOpt = DefaultOptionCreator.outputOption().create();

Option helpOpt = DefaultOptionCreator.helpOption();

Group group = gbuilder.withName("Options").withOption(inputOpt).withOption(datasetOpt).withOption(modelOpt)
        .withOption(outputOpt).withOption(helpOpt).create();

try {
  Parser parser = new Parser();
  parser.setGroup(group);
  CommandLine cmdLine = parser.parse(args);

  if (cmdLine.hasOption("help")) {
    CommandLineUtil.printHelp(group);
    return -1;
  }

  dataName = cmdLine.getValue(inputOpt).toString();
  String datasetName = cmdLine.getValue(datasetOpt).toString();
  String modelName = cmdLine.getValue(modelOpt).toString();
  String outputName = cmdLine.hasOption(outputOpt) ? cmdLine.getValue(outputOpt).toString() : null;

  if (log.isDebugEnabled()) {
    log.debug("inout     : {}", dataName);
    log.debug("dataset   : {}", datasetName);
    log.debug("model     : {}", modelName);
    log.debug("output    : {}", outputName);
  }

  dataPath = new Path(dataName);
  datasetPath = new Path(datasetName);
  modelPath = new Path(modelName);
  if (outputName != null) {
    outputPath = new Path(outputName);
  }

} catch (OptionException e) {

     log.warn(e.toString(), e);
  CommandLineUtil.printHelp(group);
  return -1;

}

time = System.currentTimeMillis();

testModel();

time = System.currentTimeMillis() - time;

writeToFileClassifyTime(Chi_RWCSUtils.elapsedTime(time));

   return 0;
 }
项目:Chi-FRBCS-BigDataCS    文件:Describe.java   
public static void main(String[] args) throws IOException, DescriptorException {

    DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
    ArgumentBuilder abuilder = new ArgumentBuilder();
    GroupBuilder gbuilder = new GroupBuilder();

    Option pathOpt = obuilder.withLongName("path").withShortName("p").withRequired(true).withArgument(
        abuilder.withName("path").withMinimum(1).withMaximum(1).create()).withDescription("Data path").create();

    Option descriptorOpt = obuilder.withLongName("descriptor").withShortName("d").withRequired(true)
        .withArgument(abuilder.withName("descriptor").withMinimum(1).create()).withDescription(
            "data descriptor").create();

    Option descPathOpt = obuilder.withLongName("file").withShortName("f").withRequired(true).withArgument(
        abuilder.withName("file").withMinimum(1).withMaximum(1).create()).withDescription(
        "Path to generated descriptor file").create();

    Option regOpt = obuilder.withLongName("regression").withDescription("Regression Problem").withShortName("r")
        .create();

    Option helpOpt = obuilder.withLongName("help").withDescription("Print out help").withShortName("h")
        .create();

    Group group = gbuilder.withName("Options").withOption(pathOpt).withOption(descPathOpt).withOption(
        descriptorOpt).withOption(regOpt).withOption(helpOpt).create();

    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);

      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }

      String dataPath = cmdLine.getValue(pathOpt).toString();
      String descPath = cmdLine.getValue(descPathOpt).toString();
      List<String> descriptor = convert(cmdLine.getValues(descriptorOpt));
      boolean regression = cmdLine.hasOption(regOpt);

      log.debug("Data path : {}", dataPath);
      log.debug("Descriptor path : {}", descPath);
      log.debug("Descriptor : {}", descriptor);
      log.debug("Regression : {}", regression);

      runTool(dataPath, descriptor, descPath, regression);
    } catch (OptionException e) {
      log.warn(e.toString());
      CommandLineUtil.printHelp(group);
    }
  }
项目:Chi-FRBCS-BigData-Ave    文件:TestModel.java   
@Override
 public int run(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
 // TODO Auto-generated method stub
   DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
   ArgumentBuilder abuilder = new ArgumentBuilder();
   GroupBuilder gbuilder = new GroupBuilder();

   Option inputOpt = DefaultOptionCreator.inputOption().create();

   Option datasetOpt = obuilder.withLongName("dataset").withShortName("ds").withRequired(true).withArgument(
      abuilder.withName("dataset").withMinimum(1).withMaximum(1).create()).withDescription("Dataset path")
        .create();

   Option modelOpt = obuilder.withLongName("model").withShortName("m").withRequired(true).withArgument(
        abuilder.withName("path").withMinimum(1).withMaximum(1).create()).
        withDescription("Path to the Model").create();

Option outputOpt = DefaultOptionCreator.outputOption().create();

Option helpOpt = DefaultOptionCreator.helpOption();

Group group = gbuilder.withName("Options").withOption(inputOpt).withOption(datasetOpt).withOption(modelOpt)
        .withOption(outputOpt).withOption(helpOpt).create();

try {
  Parser parser = new Parser();
  parser.setGroup(group);
  CommandLine cmdLine = parser.parse(args);

  if (cmdLine.hasOption("help")) {
    CommandLineUtil.printHelp(group);
    return -1;
  }

  dataName = cmdLine.getValue(inputOpt).toString();
  String datasetName = cmdLine.getValue(datasetOpt).toString();
  String modelName = cmdLine.getValue(modelOpt).toString();
  String outputName = cmdLine.hasOption(outputOpt) ? cmdLine.getValue(outputOpt).toString() : null;

  if (log.isDebugEnabled()) {
    log.debug("inout     : {}", dataName);
    log.debug("dataset   : {}", datasetName);
    log.debug("model     : {}", modelName);
    log.debug("output    : {}", outputName);
  }

  dataPath = new Path(dataName);
  datasetPath = new Path(datasetName);
  modelPath = new Path(modelName);
  if (outputName != null) {
    outputPath = new Path(outputName);
  }

} catch (OptionException e) {

     log.warn(e.toString(), e);
  CommandLineUtil.printHelp(group);
  return -1;

}

time = System.currentTimeMillis();

testModel();

time = System.currentTimeMillis() - time;

writeToFileClassifyTime(Chi_RWUtils.elapsedTime(time));

   return 0;
 }
项目:Chi-FRBCS-BigData-Ave    文件:Describe.java   
public static void main(String[] args) throws IOException, DescriptorException {

    DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
    ArgumentBuilder abuilder = new ArgumentBuilder();
    GroupBuilder gbuilder = new GroupBuilder();

    Option pathOpt = obuilder.withLongName("path").withShortName("p").withRequired(true).withArgument(
        abuilder.withName("path").withMinimum(1).withMaximum(1).create()).withDescription("Data path").create();

    Option descriptorOpt = obuilder.withLongName("descriptor").withShortName("d").withRequired(true)
        .withArgument(abuilder.withName("descriptor").withMinimum(1).create()).withDescription(
            "data descriptor").create();

    Option descPathOpt = obuilder.withLongName("file").withShortName("f").withRequired(true).withArgument(
        abuilder.withName("file").withMinimum(1).withMaximum(1).create()).withDescription(
        "Path to generated descriptor file").create();

    Option regOpt = obuilder.withLongName("regression").withDescription("Regression Problem").withShortName("r")
        .create();

    Option helpOpt = obuilder.withLongName("help").withDescription("Print out help").withShortName("h")
        .create();

    Group group = gbuilder.withName("Options").withOption(pathOpt).withOption(descPathOpt).withOption(
        descriptorOpt).withOption(regOpt).withOption(helpOpt).create();

    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);

      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }

      String dataPath = cmdLine.getValue(pathOpt).toString();
      String descPath = cmdLine.getValue(descPathOpt).toString();
      List<String> descriptor = convert(cmdLine.getValues(descriptorOpt));
      boolean regression = cmdLine.hasOption(regOpt);

      log.debug("Data path : {}", dataPath);
      log.debug("Descriptor path : {}", descPath);
      log.debug("Descriptor : {}", descriptor);
      log.debug("Regression : {}", regression);

      runTool(dataPath, descriptor, descPath, regression);
    } catch (OptionException e) {
      log.warn(e.toString());
      CommandLineUtil.printHelp(group);
    }
  }
项目:Chi-FRBCS-BigData-Max    文件:TestModel.java   
@Override
 public int run(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
 // TODO Auto-generated method stub
   DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
   ArgumentBuilder abuilder = new ArgumentBuilder();
   GroupBuilder gbuilder = new GroupBuilder();

   Option inputOpt = DefaultOptionCreator.inputOption().create();

   Option datasetOpt = obuilder.withLongName("dataset").withShortName("ds").withRequired(true).withArgument(
      abuilder.withName("dataset").withMinimum(1).withMaximum(1).create()).withDescription("Dataset path")
        .create();

   Option modelOpt = obuilder.withLongName("model").withShortName("m").withRequired(true).withArgument(
        abuilder.withName("path").withMinimum(1).withMaximum(1).create()).
        withDescription("Path to the Model").create();

Option outputOpt = DefaultOptionCreator.outputOption().create();

Option helpOpt = DefaultOptionCreator.helpOption();

Group group = gbuilder.withName("Options").withOption(inputOpt).withOption(datasetOpt).withOption(modelOpt)
        .withOption(outputOpt).withOption(helpOpt).create();

try {
  Parser parser = new Parser();
  parser.setGroup(group);
  CommandLine cmdLine = parser.parse(args);

  if (cmdLine.hasOption("help")) {
    CommandLineUtil.printHelp(group);
    return -1;
  }

  dataName = cmdLine.getValue(inputOpt).toString();
  String datasetName = cmdLine.getValue(datasetOpt).toString();
  String modelName = cmdLine.getValue(modelOpt).toString();
  String outputName = cmdLine.hasOption(outputOpt) ? cmdLine.getValue(outputOpt).toString() : null;

  if (log.isDebugEnabled()) {
    log.debug("inout     : {}", dataName);
    log.debug("dataset   : {}", datasetName);
    log.debug("model     : {}", modelName);
    log.debug("output    : {}", outputName);
  }

  dataPath = new Path(dataName);
  datasetPath = new Path(datasetName);
  modelPath = new Path(modelName);
  if (outputName != null) {
    outputPath = new Path(outputName);
  }

} catch (OptionException e) {

     log.warn(e.toString(), e);
  CommandLineUtil.printHelp(group);
  return -1;

}

time = System.currentTimeMillis();

testModel();

time = System.currentTimeMillis() - time;

writeToFileClassifyTime(Chi_RWCSUtils.elapsedTime(time));

   return 0;
 }
项目:Chi-FRBCS-BigData-Max    文件:Describe.java   
public static void main(String[] args) throws IOException, DescriptorException {

    DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
    ArgumentBuilder abuilder = new ArgumentBuilder();
    GroupBuilder gbuilder = new GroupBuilder();

    Option pathOpt = obuilder.withLongName("path").withShortName("p").withRequired(true).withArgument(
        abuilder.withName("path").withMinimum(1).withMaximum(1).create()).withDescription("Data path").create();

    Option descriptorOpt = obuilder.withLongName("descriptor").withShortName("d").withRequired(true)
        .withArgument(abuilder.withName("descriptor").withMinimum(1).create()).withDescription(
            "data descriptor").create();

    Option descPathOpt = obuilder.withLongName("file").withShortName("f").withRequired(true).withArgument(
        abuilder.withName("file").withMinimum(1).withMaximum(1).create()).withDescription(
        "Path to generated descriptor file").create();

    Option regOpt = obuilder.withLongName("regression").withDescription("Regression Problem").withShortName("r")
        .create();

    Option helpOpt = obuilder.withLongName("help").withDescription("Print out help").withShortName("h")
        .create();

    Group group = gbuilder.withName("Options").withOption(pathOpt).withOption(descPathOpt).withOption(
        descriptorOpt).withOption(regOpt).withOption(helpOpt).create();

    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);

      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }

      String dataPath = cmdLine.getValue(pathOpt).toString();
      String descPath = cmdLine.getValue(descPathOpt).toString();
      List<String> descriptor = convert(cmdLine.getValues(descriptorOpt));
      boolean regression = cmdLine.hasOption(regOpt);

      log.debug("Data path : {}", dataPath);
      log.debug("Descriptor path : {}", descPath);
      log.debug("Descriptor : {}", descriptor);
      log.debug("Regression : {}", regression);

      runTool(dataPath, descriptor, descPath, regression);
    } catch (OptionException e) {
      log.warn(e.toString());
      CommandLineUtil.printHelp(group);
    }
  }
项目:Chi-FRBCS-BigData-Max    文件:TestModel.java   
@Override
 public int run(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
 // TODO Auto-generated method stub
   DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
   ArgumentBuilder abuilder = new ArgumentBuilder();
   GroupBuilder gbuilder = new GroupBuilder();

   Option inputOpt = DefaultOptionCreator.inputOption().create();

   Option datasetOpt = obuilder.withLongName("dataset").withShortName("ds").withRequired(true).withArgument(
      abuilder.withName("dataset").withMinimum(1).withMaximum(1).create()).withDescription("Dataset path")
        .create();

   Option modelOpt = obuilder.withLongName("model").withShortName("m").withRequired(true).withArgument(
        abuilder.withName("path").withMinimum(1).withMaximum(1).create()).
        withDescription("Path to the Model").create();

Option outputOpt = DefaultOptionCreator.outputOption().create();

Option helpOpt = DefaultOptionCreator.helpOption();

Group group = gbuilder.withName("Options").withOption(inputOpt).withOption(datasetOpt).withOption(modelOpt)
        .withOption(outputOpt).withOption(helpOpt).create();

try {
  Parser parser = new Parser();
  parser.setGroup(group);
  CommandLine cmdLine = parser.parse(args);

  if (cmdLine.hasOption("help")) {
    CommandLineUtil.printHelp(group);
    return -1;
  }

  dataName = cmdLine.getValue(inputOpt).toString();
  String datasetName = cmdLine.getValue(datasetOpt).toString();
  String modelName = cmdLine.getValue(modelOpt).toString();
  String outputName = cmdLine.hasOption(outputOpt) ? cmdLine.getValue(outputOpt).toString() : null;

  if (log.isDebugEnabled()) {
    log.debug("inout     : {}", dataName);
    log.debug("dataset   : {}", datasetName);
    log.debug("model     : {}", modelName);
    log.debug("output    : {}", outputName);
  }

  dataPath = new Path(dataName);
  datasetPath = new Path(datasetName);
  modelPath = new Path(modelName);
  if (outputName != null) {
    outputPath = new Path(outputName);
  }

} catch (OptionException e) {

     log.warn(e.toString(), e);
  CommandLineUtil.printHelp(group);
  return -1;

}

time = System.currentTimeMillis();

testModel();

time = System.currentTimeMillis() - time;

writeToFileClassifyTime(Chi_RWUtils.elapsedTime(time));

   return 0;
 }
项目:Chi-FRBCS-BigData-Max    文件:Describe.java   
public static void main(String[] args) throws IOException, DescriptorException {

    DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
    ArgumentBuilder abuilder = new ArgumentBuilder();
    GroupBuilder gbuilder = new GroupBuilder();

    Option pathOpt = obuilder.withLongName("path").withShortName("p").withRequired(true).withArgument(
        abuilder.withName("path").withMinimum(1).withMaximum(1).create()).withDescription("Data path").create();

    Option descriptorOpt = obuilder.withLongName("descriptor").withShortName("d").withRequired(true)
        .withArgument(abuilder.withName("descriptor").withMinimum(1).create()).withDescription(
            "data descriptor").create();

    Option descPathOpt = obuilder.withLongName("file").withShortName("f").withRequired(true).withArgument(
        abuilder.withName("file").withMinimum(1).withMaximum(1).create()).withDescription(
        "Path to generated descriptor file").create();

    Option regOpt = obuilder.withLongName("regression").withDescription("Regression Problem").withShortName("r")
        .create();

    Option helpOpt = obuilder.withLongName("help").withDescription("Print out help").withShortName("h")
        .create();

    Group group = gbuilder.withName("Options").withOption(pathOpt).withOption(descPathOpt).withOption(
        descriptorOpt).withOption(regOpt).withOption(helpOpt).create();

    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);

      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }

      String dataPath = cmdLine.getValue(pathOpt).toString();
      String descPath = cmdLine.getValue(descPathOpt).toString();
      List<String> descriptor = convert(cmdLine.getValues(descriptorOpt));
      boolean regression = cmdLine.hasOption(regOpt);

      log.debug("Data path : {}", dataPath);
      log.debug("Descriptor path : {}", descPath);
      log.debug("Descriptor : {}", descriptor);
      log.debug("Regression : {}", regression);

      runTool(dataPath, descriptor, descPath, regression);
    } catch (OptionException e) {
      log.warn(e.toString());
      CommandLineUtil.printHelp(group);
    }
  }
项目:jnrpe    文件:JNRPEClient.java   
/**
 * 
 * @param args
 *            command line arguments
 *             -
 */
public static void main(final String[] args) {

    Parser parser = new Parser();
    parser.setGroup(configureCommandLine());

    CommandLine cli = null;

    try {
        cli = parser.parse(args);

        if (cli.hasOption("--help")) {
            printUsage(null);
        }

        //timeoutAsUnknown = cli.hasOption("--unknown");

        String sHost = (String) cli.getValue("--host");
        final Long port = (Long) cli.getValue("--port", Long.valueOf(DEFAULT_PORT));
        String sCommand = (String) cli.getValue("--command", "_NRPE_CHECK");

        JNRPEClient client = new JNRPEClient(sHost, port.intValue(), !cli.hasOption("--nossl"));
        client.setTimeout(((Long) cli.getValue("--timeout", Long.valueOf(DEFAULT_TIMEOUT))).intValue());

        if (cli.hasOption("--weakCiherSuites")) {
            client.enableWeakCipherSuites();
        }

        @SuppressWarnings("unchecked")
        List<String> argList = cli.getValues("--arglist");
        ReturnValue ret = client.sendCommand(sCommand, argList.toArray(new String[argList.size()]));

        System.out.println(ret.getMessage());
        System.exit(ret.getStatus().intValue());
    } catch (JNRPEClientException exc) {
        Status returnStatus;

        Throwable cause = exc.getCause();
        if (cli.hasOption("--unknown") && cause instanceof SocketTimeoutException) {
            returnStatus = Status.UNKNOWN;
        } else {
            returnStatus = Status.CRITICAL;
        }

        System.out.println(exc.getMessage());
        System.exit(returnStatus.intValue());
    } catch (OptionException oe) {
        printUsage(oe);
    }
}