use of net.sourceforge.argparse4j.inf.ArgumentParser 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.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));
}
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);
// defaults for flags
when(options.getString("job")).thenReturn(null);
when(options.getString("host")).thenReturn("");
}
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"));
}
}
use of net.sourceforge.argparse4j.inf.ArgumentParser in project apache-kafka-on-k8s by banzaicloud.
the class VerifiableConsumer method argParser.
private static ArgumentParser argParser() {
ArgumentParser parser = ArgumentParsers.newArgumentParser("verifiable-consumer").defaultHelp(true).description("This tool consumes messages from a specific topic and emits consumer events (e.g. group rebalances, received messages, and offsets committed) as JSON objects to STDOUT.");
parser.addArgument("--broker-list").action(store()).required(true).type(String.class).metavar("HOST1:PORT1[,HOST2:PORT2[...]]").dest("brokerList").help("Comma-separated list of Kafka brokers in the form HOST1:PORT1,HOST2:PORT2,...");
parser.addArgument("--topic").action(store()).required(true).type(String.class).metavar("TOPIC").help("Consumes messages from this topic.");
parser.addArgument("--group-id").action(store()).required(true).type(String.class).metavar("GROUP_ID").dest("groupId").help("The groupId shared among members of the consumer group");
parser.addArgument("--max-messages").action(store()).required(false).type(Integer.class).setDefault(-1).metavar("MAX-MESSAGES").dest("maxMessages").help("Consume this many messages. If -1 (the default), the consumer will consume until the process is killed externally");
parser.addArgument("--session-timeout").action(store()).required(false).setDefault(30000).type(Integer.class).metavar("TIMEOUT_MS").dest("sessionTimeout").help("Set the consumer's session timeout");
parser.addArgument("--verbose").action(storeTrue()).type(Boolean.class).metavar("VERBOSE").help("Enable to log individual consumed records");
parser.addArgument("--enable-autocommit").action(storeTrue()).type(Boolean.class).metavar("ENABLE-AUTOCOMMIT").dest("useAutoCommit").help("Enable offset auto-commit on consumer");
parser.addArgument("--reset-policy").action(store()).required(false).setDefault("earliest").type(String.class).dest("resetPolicy").help("Set reset policy (must be either 'earliest', 'latest', or 'none'");
parser.addArgument("--assignment-strategy").action(store()).required(false).setDefault(RangeAssignor.class.getName()).type(String.class).dest("assignmentStrategy").help("Set assignment strategy (e.g. " + RoundRobinAssignor.class.getName() + ")");
parser.addArgument("--consumer.config").action(store()).required(false).type(String.class).metavar("CONFIG_FILE").help("Consumer config properties file (config options shared with command line parameters will be overridden).");
return parser;
}
Aggregations