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());
}
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());
}
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());
}
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);
}
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"));
}
}
Aggregations