Search in sources :

Example 41 with Namespace

use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.

the class DbStatusCommandTest method testRun.

@Test
public void testRun() throws Exception {
    statusCommand.run(null, new Namespace(ImmutableMap.of()), conf);
    assertThat(baos.toString(UTF_8)).matches("3 change sets have not been applied to \\S+" + System.lineSeparator());
}
Also used : Namespace(net.sourceforge.argparse4j.inf.Namespace) Test(org.junit.Test)

Example 42 with Namespace

use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.

the class DbStatusCommandTest method testRunOnMigratedDb.

@Test
public void testRunOnMigratedDb() throws Exception {
    final String existedDbPath = new File(Resources.getResource("test-db.mv.db").toURI()).getAbsolutePath();
    final String existedDbUrl = "jdbc:h2:" + StringUtils.removeEnd(existedDbPath, ".mv.db");
    final TestMigrationConfiguration existedDbConf = createConfiguration(existedDbUrl);
    statusCommand.run(null, new Namespace(ImmutableMap.of()), existedDbConf);
    assertThat(baos.toString(UTF_8)).matches("\\S+ is up to date" + System.lineSeparator());
}
Also used : File(java.io.File) Namespace(net.sourceforge.argparse4j.inf.Namespace) Test(org.junit.Test)

Example 43 with Namespace

use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.

the class DbStatusCommandTest method testVerbose.

@Test
public void testVerbose() throws Exception {
    statusCommand.run(null, new Namespace(ImmutableMap.of("verbose", (Object) true)), conf);
    assertThat(baos.toString(UTF_8)).matches("3 change sets have not been applied to \\S+" + System.lineSeparator() + "\\s*migrations\\.xml::1::db_dev" + System.lineSeparator() + "\\s*migrations\\.xml::2::db_dev" + System.lineSeparator() + "\\s*migrations\\.xml::3::db_dev" + System.lineSeparator());
}
Also used : Namespace(net.sourceforge.argparse4j.inf.Namespace) Test(org.junit.Test)

Example 44 with Namespace

use of net.sourceforge.argparse4j.inf.Namespace in project helios by spotify.

the class HostListCommandTest method runCommand.

private int runCommand(String... commandArgs) throws ExecutionException, InterruptedException, ArgumentParserException {
    final String[] args = new String[1 + commandArgs.length];
    args[0] = "hosts";
    System.arraycopy(commandArgs, 0, args, 1, commandArgs.length);
    // use a real, dummy Subparser impl to avoid having to mock out every single call
    final ArgumentParser parser = ArgumentParsers.newArgumentParser("test");
    final Subparser subparser = parser.addSubparsers().addParser("hosts");
    final HostListCommand command = new HostListCommand(subparser);
    final Namespace options = parser.parseArgs(args);
    return command.run(options, client, out, false, null);
}
Also used : Subparser(net.sourceforge.argparse4j.inf.Subparser) Matchers.containsString(org.hamcrest.Matchers.containsString) ArgumentParser(net.sourceforge.argparse4j.inf.ArgumentParser) Namespace(net.sourceforge.argparse4j.inf.Namespace)

Example 45 with Namespace

use of net.sourceforge.argparse4j.inf.Namespace in project cogcomp-nlp by CogComp.

the class MainClass method main.

public static void main(String[] args) throws Exception {
    ArgumentParser parser = ArgumentParsers.newArgumentParser("MainClass", true);
    parser.addArgument("-r", "--train").type(String.class).help("The training file in CoNLL format").setDefault("");
    parser.addArgument("-t", "--test").help("The test file in CoNLL format");
    parser.addArgument("-c", "--config").help("The SL configuration file").setDefault("config/StructuredPerceptron.config");
    parser.addArgument("-m", "--model").help("The model output file").setDefault("out.model");
    parser.addArgument("-p", "--pos").help("The type of PoS tags to use").choices("gold", "auto").setDefault("auto");
    parser.addArgument("-o", "--offset").type(Integer.class).help("The offset of the pos/head/dep index for the CoNLL train/test files").setDefault(0);
    parser.addArgument("-a", "--annotate").type(String.class).help("Annotate text file (one sentence per line) and print the output to the command line").setDefault("");
    Namespace ns = parser.parseArgs(args);
    useGoldPOS = ns.getString("pos").equals("gold");
    logger.info("Using {} PoS tags", ns.getString("pos"));
    conllIndexOffset = ns.getInt("offset");
    if (!ns.getString("train").isEmpty()) {
        logger.info("Using {} configuration", ns.getString("config"));
        train(ns.getString("train"), ns.getString("config"), ns.getString("model"));
        logger.info("Testing on Training Data");
        test(ns.getString("model"), ns.getString("train"), false);
    }
    if (!ns.getString("test").isEmpty()) {
        logger.info("Testing on Test Data");
        test(ns.getString("model"), ns.getString("test"), true);
    }
    if (!ns.getString("annotate").isEmpty()) {
        annotate(ns.getString("annotate"));
    }
}
Also used : ArgumentParser(net.sourceforge.argparse4j.inf.ArgumentParser) Namespace(net.sourceforge.argparse4j.inf.Namespace)

Aggregations

Namespace (net.sourceforge.argparse4j.inf.Namespace)46 Test (org.junit.Test)36 PrintStream (java.io.PrintStream)9 Handle (org.skife.jdbi.v2.Handle)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 Liquibase (liquibase.Liquibase)6 ArgumentParserException (net.sourceforge.argparse4j.inf.ArgumentParserException)6 DBI (org.skife.jdbi.v2.DBI)6 ArgumentParser (net.sourceforge.argparse4j.inf.ArgumentParser)5 IOException (java.io.IOException)4 Properties (java.util.Properties)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 File (java.io.File)3 Configuration (io.dropwizard.Configuration)2 Bootstrap (io.dropwizard.setup.Bootstrap)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Element (org.w3c.dom.Element)2