Search in sources :

Example 16 with ArgumentParser

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

the class JobCreateCommandTest method setUp.

@Before
public void setUp() {
    // 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("create");
    final Supplier<Map<String, String>> envVarSupplier = new Supplier<Map<String, String>>() {

        @Override
        public Map<String, String> get() {
            return ImmutableMap.copyOf(envVars);
        }
    };
    command = new JobCreateCommand(subparser, envVarSupplier);
    when(client.createJob(argThat(matchesName(JOB_NAME)))).thenReturn(immediateFuture(new CreateJobResponse(CreateJobResponse.Status.OK, Collections.<String>emptyList(), "12345")));
}
Also used : CreateJobResponse(com.spotify.helios.common.protocol.CreateJobResponse) Subparser(net.sourceforge.argparse4j.inf.Subparser) Supplier(com.google.common.base.Supplier) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentParser(net.sourceforge.argparse4j.inf.ArgumentParser) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Before(org.junit.Before)

Example 17 with ArgumentParser

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

the class JobInspectCommandTest method setUp.

@Before
public void setUp() {
    // 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("inspect");
    command = new JobInspectCommand(subparser, TimeZone.getTimeZone("UTC"));
    when(client.jobs(JOB_NAME_VERSION)).thenReturn(Futures.immediateFuture(jobs));
}
Also used : Subparser(net.sourceforge.argparse4j.inf.Subparser) ArgumentParser(net.sourceforge.argparse4j.inf.ArgumentParser) Before(org.junit.Before)

Example 18 with ArgumentParser

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

the class JobStatusCommandTest method setUp.

@Before
public void setUp() {
    // 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("list");
    command = new JobStatusCommand(subparser);
}
Also used : Subparser(net.sourceforge.argparse4j.inf.Subparser) ArgumentParser(net.sourceforge.argparse4j.inf.ArgumentParser) Before(org.junit.Before)

Example 19 with ArgumentParser

use of net.sourceforge.argparse4j.inf.ArgumentParser 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)

Example 20 with ArgumentParser

use of net.sourceforge.argparse4j.inf.ArgumentParser in project pcgen by PCGen.

the class Main method getParser.

/**
	 * @return an ArgumentParser used to peform argument parsing
	 */
private static ArgumentParser getParser() {
    ArgumentParser parser = ArgumentParsers.newArgumentParser(Constants.APPLICATION_NAME).defaultHelp(false).description("RPG Character Generator").version(PCGenPropBundle.getVersionNumber());
    parser.addArgument("-v", "--verbose").help("verbose logging").type(Boolean.class).action(Arguments.count());
    parser.addArgument("-V", "--version").action(Arguments.version());
    parser.addArgument("-J").help("ignore java version checks").action(Arguments.storeTrue());
    MutuallyExclusiveGroup startupMode = parser.addMutuallyExclusiveGroup().description("start up on a specific mode");
    startupMode.addArgument("-G", "--gmgen").help("GMGen mode").type(Boolean.class).action(Arguments.storeTrue());
    startupMode.addArgument("-N", "--npc").help("NPC generation mode").type(Boolean.class).action(Arguments.storeTrue());
    startupMode.addArgument("--name-generator").help("run the name generator").type(Boolean.class).action(Arguments.storeTrue());
    startupMode.addArgument("-D", "--tab").nargs(1);
    parser.addArgument("-s", "--settingsdir").nargs(1).type(Arguments.fileType().verifyIsDirectory().verifyCanRead().verifyExists());
    parser.addArgument("-m", "--campaignmode").nargs(1).type(String.class);
    parser.addArgument("-E", "--exportsheet").nargs(1).type(Arguments.fileType().verifyCanRead().verifyExists().verifyIsFile());
    parser.addArgument("-o", "--outputfile").nargs(1).type(Arguments.fileType().verifyCanCreate().verifyCanWrite().verifyNotExists());
    parser.addArgument("-c", "--character").nargs(1).type(Arguments.fileType().verifyCanRead().verifyExists().verifyIsFile());
    parser.addArgument("-p", "--party").nargs(1).type(Arguments.fileType().verifyCanRead().verifyExists().verifyIsFile());
    return parser;
}
Also used : MutuallyExclusiveGroup(net.sourceforge.argparse4j.inf.MutuallyExclusiveGroup) ArgumentParser(net.sourceforge.argparse4j.inf.ArgumentParser)

Aggregations

ArgumentParser (net.sourceforge.argparse4j.inf.ArgumentParser)20 Subparser (net.sourceforge.argparse4j.inf.Subparser)8 Before (org.junit.Before)7 Namespace (net.sourceforge.argparse4j.inf.Namespace)6 ArgumentParserException (net.sourceforge.argparse4j.inf.ArgumentParserException)5 Properties (java.util.Properties)3 IOException (java.io.IOException)2 MutuallyExclusiveGroup (net.sourceforge.argparse4j.inf.MutuallyExclusiveGroup)2 Supplier (com.google.common.base.Supplier)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 DeploymentGroup (com.spotify.helios.common.descriptors.DeploymentGroup)1 JobId (com.spotify.helios.common.descriptors.JobId)1 JobStatus (com.spotify.helios.common.descriptors.JobStatus)1 CreateJobResponse (com.spotify.helios.common.protocol.CreateJobResponse)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Random (java.util.Random)1 RoundRobinAssignor (org.apache.kafka.clients.consumer.RoundRobinAssignor)1