当前位置: 首页>>代码示例>>Java>>正文


Java Namespace.getBoolean方法代码示例

本文整理汇总了Java中net.sourceforge.argparse4j.inf.Namespace.getBoolean方法的典型用法代码示例。如果您正苦于以下问题:Java Namespace.getBoolean方法的具体用法?Java Namespace.getBoolean怎么用?Java Namespace.getBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sourceforge.argparse4j.inf.Namespace的用法示例。


在下文中一共展示了Namespace.getBoolean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
protected void run(Bootstrap<EmoConfiguration> bootstrap, Namespace namespace, EmoConfiguration emoConfiguration)
        throws Exception {
    _outputOnly = namespace.getBoolean("output_only");

    DdlConfiguration ddlConfiguration = parseDdlConfiguration(toFile(namespace.getString("config-ddl")));
    CuratorFramework curator = null;
    if (!_outputOnly) {
        curator = emoConfiguration.getZooKeeperConfiguration().newCurator();
        curator.start();
    }
    try {
        createKeyspacesIfNecessary(emoConfiguration, ddlConfiguration, curator, bootstrap.getMetricRegistry());

    } finally {
        Closeables.close(curator, true);
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:19,代码来源:CreateKeyspacesCommand.java

示例2: main

import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
public static void main(String[] args) {
    ArgumentParser parser = ArgumentParsers.newArgumentParser("AngusMe");
    parser.description("Angus SDK configurator");

    parser.addArgument("-s", "--show").action(Arguments.storeTrue())
            .help("display current configuration if exists");

    parser.addArgument("-d", "--delete").action(Arguments.storeTrue())
            .help("remove current configuration if exists");

    try {
        Namespace res = parser.parseArgs(args);
        if (res.getBoolean("show")) {
            show();
        } else if (res.getBoolean("delete")) {
            delete();
        } else {
            update();
        }
    } catch (ArgumentParserException e) {
        parser.handleError(e);
    }
}
 
开发者ID:angus-ai,项目名称:angus-sdk-java,代码行数:24,代码来源:AngusMe.java

示例3: run

import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
public void run(Bootstrap<?> bootstrap, Namespace namespace) throws Exception {
    try {
        final Path configPath = Paths.get(WORKSPACE_CONFIG_FILENAME);
        tryWriteFile(configPath, openResourceFile("config-template.yml"));

        final Path usersPath = Paths.get(WORKSPACE_USER_FILENAME);
        tryWriteFile(usersPath, toInputStream(""));

        final Path specDir = Paths.get(WORKSPACE_SPECS_DIRNAME);
        tryCreateDir(specDir);

        if (namespace.getBoolean(DEMO_ARG_NAME)) {
            tryWriteDemoSpec(specDir);
        }

        final Path jobsDir = Paths.get(WORKSPACE_JOBS_DIRNAME);
        tryCreateDir(jobsDir);

        final Path wdsDir = Paths.get(WORKSPACE_WDS_DIRNAME);
        tryCreateDir(wdsDir);

        System.out.println("Deployment created. Remember to add users (`user add`, `user passwd`), specs (`generate spec`), and boot the server (`serve`)");
        System.exit(0);
    } catch (IOException ex) {
        System.err.println(ex.toString());
        System.err.println(
                "Error creating jobson files/directories. Do you have file permissions? " +
                "Could some of the files already exist (this app won't overwrite files)?");
        System.exit(1);
    }
}
 
开发者ID:adamkewley,项目名称:jobson,代码行数:33,代码来源:NewCommand.java

示例4: main

import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	ArgumentParser parser = argParser();
	Namespace ns = null;
	try {
		ns = parser.parseArgs(args);
	} catch (ArgumentParserException e) {
		parser.handleError(e);
		System.exit(1);
	}

	String topicOrNull = ns.getString(TOPIC);
	String zookeeper = ns.getString(ZOOKEEPER);
	boolean rackAware = ns.getBoolean(RACK_AWARE);

	BrokersTopicsCache.initialize(zookeeper, rackAware);
	String assignmentPlanJsonStr = generateAssignmentPlan(ns, topicOrNull, rackAware);

	switch (ns.getString(OPERATION)) {
	case GENERATE:
		break;
	case EXECUTE:
		if (assignmentPlanJsonStr != null) {
			executePlan(zookeeper, assignmentPlanJsonStr);
		} else {
			log.info("No assignment plan generated to execute, exiting");
		}
		break;
	default:
		throw new ReplicaAssignmentException("Unknown mode: " + ns.getString(OPERATION));
	}
}
 
开发者ID:flipkart-incubator,项目名称:kafka-balancer,代码行数:32,代码来源:KafkaBalancerMain.java

示例5: main

import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
/**
 * Main function demonstrating command-line processing via argparse4j.
 *
 * @param arguments Command-line arguments.
 */
public static void main(final String[] arguments)
{
   final ArgumentParser argumentParser =
      ArgumentParsers.newArgumentParser("Main", true);
   argumentParser.addArgument("-f", "--file")
                 .dest("file")
                 .required(true)
                 .help("Path and name of file");
   argumentParser.addArgument("-v", "--verbose")
                 .dest("verbose")
                 .type(Boolean.class)
                 .nargs("?")
                 .setConst(true)
                 .help("Enable verbose output.");

   try
   {
      final Namespace response = argumentParser.parseArgs(arguments);
      final String filePathAndName = response.getString("file");
      final Boolean verbositySet = response.getBoolean("verbose");
      out.println(
           "Path/name of file is '" + filePathAndName
         + "' and verbosity is "
         + (Boolean.TRUE.equals(verbositySet) ? "SET" : "NOT SET")
         + ".");
   }
   catch (ArgumentParserException parserEx)
   {
      argumentParser.handleError(parserEx);
   }
}
 
开发者ID:dustinmarx,项目名称:java-cli-demos,代码行数:37,代码来源:Main.java

示例6: createFromArgs

import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
public static VerifiableConsumer createFromArgs(ArgumentParser parser, String[] args) throws ArgumentParserException {
    Namespace res = parser.parseArgs(args);

    String topic = res.getString("topic");
    boolean useAutoCommit = res.getBoolean("useAutoCommit");
    int maxMessages = res.getInt("maxMessages");
    boolean verbose = res.getBoolean("verbose");
    String configFile = res.getString("consumer.config");

    Properties consumerProps = new Properties();
    if (configFile != null) {
        try {
            consumerProps.putAll(Utils.loadProps(configFile));
        } catch (IOException e) {
            throw new ArgumentParserException(e.getMessage(), parser);
        }
    }

    consumerProps.put(ConsumerConfig.GROUP_ID_CONFIG, res.getString("groupId"));
    consumerProps.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, res.getString("brokerList"));
    consumerProps.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, useAutoCommit);
    consumerProps.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, res.getString("resetPolicy"));
    consumerProps.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, Integer.toString(res.getInt("sessionTimeout")));
    consumerProps.put(ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG, res.getString("assignmentStrategy"));

    StringDeserializer deserializer = new StringDeserializer();
    KafkaConsumer<String, String> consumer = new KafkaConsumer<>(consumerProps, deserializer, deserializer);

    return new VerifiableConsumer(
            consumer,
            System.out,
            topic,
            maxMessages,
            useAutoCommit,
            false,
            verbose);
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:38,代码来源:VerifiableConsumer.java

示例7: TestConfig

import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
TestConfig(Namespace res) {
    this.bootstrapServer = res.getString("bootstrapServer");
    this.topic = res.getString("topic");
    this.offsetsForTimesSupported = res.getBoolean("offsetsForTimesSupported");
    this.expectClusterId = res.getBoolean("clusterIdSupported");
    this.expectRecordTooLargeException = res.getBoolean("expectRecordTooLargeException");
    this.numClusterNodes = res.getInt("numClusterNodes");
    this.createTopicsSupported = res.getBoolean("createTopicsSupported");
    this.describeAclsSupported = res.getBoolean("describeAclsSupported");
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:11,代码来源:ClientCompatibilityTest.java

示例8: main

import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
/**
 * Cluster the C-alpha chains of a set of PDB ids.
 * @param args the input args - currently none taken
 * @throws IOException an error reading from the URL or the seqeunce file
 */
public static void main(String[] args) throws IOException {
	// Read the arguments
	Namespace ns = parseArgs(args);
	// Get the actual arguments
	String alignMethod = ns.getString("align");
	String filePath = ns.getString("hadoop");
	int minLength = ns.getInt("minlength");
	double sample = ns.getDouble("sample");
	boolean useFiles = ns.getBoolean("files");
	
	// Get the list of PDB ids
	List<String> pdbIdList = ns.<String> getList("pdbId");

	// Get the chains that correpspond to that
	JavaPairRDD<String, Atom[]>  chainRDD;
	if(pdbIdList.size()>0){
		if(useFiles==true){
			StructureDataRDD structureDataRDD = new StructureDataRDD(
					BiojavaSparkUtils.getFromList(convertToFiles(pdbIdList))
					.mapToPair(t -> new Tuple2<String, StructureDataInterface>(t._1, BiojavaSparkUtils.convertToStructDataInt(t._2))));
			chainRDD = BiojavaSparkUtils.getChainRDD(structureDataRDD, minLength);

		}
		else{
			chainRDD = BiojavaSparkUtils.getChainRDD(pdbIdList, minLength);
		}
	}
	else if(!filePath.equals(defaultPath)){
		chainRDD = BiojavaSparkUtils.getChainRDD(filePath, minLength, sample);
	}
	else{
		System.out.println("Must specify PDB ids or an hadoop sequence file");
		return;
	}

	System.out.println("Analysisng " + chainRDD.count() + " chains");
	JavaPairRDD<Tuple2<String,Atom[]>,Tuple2<String, Atom[]>> comparisons = SparkUtils.getHalfCartesian(chainRDD, chainRDD.getNumPartitions());
	JavaRDD<Tuple3<String, String,  AFPChain>> similarities = comparisons.map(t -> new Tuple3<String, String, AFPChain>(t._1._1, t._2._1, 
			AlignmentTools.getBiojavaAlignment(t._1._2, t._2._2, alignMethod)));
	JavaRDD<Tuple6<String, String, Double, Double, Double, Double>> allScores = similarities.map(t -> new Tuple6<String, String, Double, Double, Double, Double>(
			t._1(), t._2(), t._3().getTMScore(), t._3().getTotalRmsdOpt(),  (double) t._3().getTotalLenOpt(),  t._3().getAlignScore())).cache();
	if(alignMethod.equals("DUMMY")){
		JavaDoubleRDD doubleDist = allScores.mapToDouble(t -> t._3());
		System.out.println("Average dist: "+doubleDist.mean());
	}
	else{
		writeData(allScores);
	}
}
 
开发者ID:biojava,项目名称:biojava-spark,代码行数:55,代码来源:ChainAligner.java

示例9: main

import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
public static void main(String[] args) {
    ArgumentParser parser = ArgumentParsers.newArgumentParser("com.flurry.proguard.UploadMapping", true)
            .description("Uploads Proguard/Native Mapping Files for Android");
    parser.addArgument("-k", "--api-key").required(true)
                .help("API Key for your project");
    parser.addArgument("-u", "--uuid").required(true)
                .help("The build UUID");
    parser.addArgument("-p", "--path").required(true)
            .help("Path to ProGuard/Native mapping file for the build");
    parser.addArgument("-t", "--token").required(true)
                .help("A Flurry auth token to use for the upload");
    parser.addArgument("-to", "--timeout").type(Integer.class).setDefault(TEN_MINUTES_IN_MS)
                .help("How long to wait (in ms) for the upload to be processed");
    parser.addArgument("-n", "--ndk").type(Boolean.class).setDefault(false)
                .help("Is it a Native mapping file");

    Namespace res = null;
    try {
        res = parser.parseArgs(args);
    } catch (ArgumentParserException e) {
        parser.handleError(e);
        System.exit(1);
    }

    EXIT_PROCESS_ON_ERROR = true;
    if (res.getBoolean("ndk")) {
        uploadFiles(res.getString("api_key"), res.getString("uuid"),
                new ArrayList<>(Collections.singletonList(res.getString("path"))),
                res.getString("token"), res.getInt("timeout"), AndroidUploadType.ANDROID_NATIVE);
    } else {
        uploadFiles(res.getString("api_key"), res.getString("uuid"),
                new ArrayList<>(Collections.singletonList(res.getString("path"))),
                res.getString("token"), res.getInt("timeout"), AndroidUploadType.ANDROID_JAVA);
    }
}
 
开发者ID:flurry,项目名称:upload-clients,代码行数:36,代码来源:UploadMapping.java

示例10: main

import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
public static void main(String[] args) throws ArgumentParserException
{
    // Constructing parser and subcommands
    ArgumentParser parser = ArgumentParsers.newArgumentParser("bunkr");

    String entrypoint = GuiEntryPoint.class.getName();
    try
    {
        entrypoint = new File(GuiEntryPoint.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getName();
    }
    catch (URISyntaxException ignored) { }

    parser.version(
            String.format("%s\nversion: %s\ncommit date: %s\ncommit hash: %s",
                          entrypoint,
                          Version.versionString,
                          Version.gitDate,
                          Version.gitHash));
    parser.addArgument("--version").action(Arguments.version());
    parser.addArgument("--logging")
            .action(Arguments.storeTrue())
            .type(Boolean.class)
            .setDefault(false)
            .help("Enable debug logging. This may be a security issue due to information leakage.");
    parser.addArgument("--file")
            .type(String.class)
            .help("Open a particular archive by file path");

    Namespace namespace = parser.parseArgs(args);
    if (namespace.getBoolean("logging"))
    {
        Logging.setEnabled(true);
        Logging.info("Logging is now enabled");
    }

    String[] guiParams = new String[]{namespace.get("file")};
    MainApplication.launch(MainApplication.class, guiParams);
}
 
开发者ID:AstromechZA,项目名称:bunkr,代码行数:39,代码来源:GuiEntryPoint.java

示例11: handle

import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
public void handle(Namespace args) throws Exception
{
    UserSecurityProvider usp = new UserSecurityProvider(makeCLIPasswordProvider(args.get(CLI.ARG_PASSWORD_FILE)));

    File archiveFile = args.get(CLI.ARG_ARCHIVE_PATH);
    if (archiveFile.exists() && !args.getBoolean(ARG_OVERWRITE))
        throw new CLIException("File %s already exists. Pass --overwrite in order to overwrite it.", archiveFile.getAbsolutePath());

    ArchiveBuilder.createNewEmptyArchive(archiveFile, new PlaintextDescriptor(), usp);
    System.out.println(String.format("Created new archive %s", archiveFile.getAbsolutePath()));
}
 
开发者ID:AstromechZA,项目名称:bunkr,代码行数:13,代码来源:CreateCommand.java

示例12: handle

import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
public void handle(Namespace args) throws Exception
{
    UserSecurityProvider usp = new UserSecurityProvider(makeCLIPasswordProvider(args.get(CLI.ARG_PASSWORD_FILE)));
    ArchiveInfoContext aic = new ArchiveInfoContext(args.get(CLI.ARG_ARCHIVE_PATH), usp);

    // first delete the correct items and collect blocks to wipe
    FragmentedRange wipeblocks = deleteItem(aic.getInventory(), args.getString(ARG_PATH), args.getBoolean(ARG_RECURSIVE));

    // save metadata as soon as possible
    MetadataWriter.write(aic, usp);
    System.out.println(String.format("Deleted %s from archive.", args.getString(ARG_PATH)));

    // now calculate which blocks we can still safely wipe (the descriptor and inventory may have landed over some)
    long usedBlocks = BlockAllocationManager.calculateUsedBlocks(aic.getInventory());
    wipeblocks.subtract(new FragmentedRange((int) usedBlocks, Integer.MAX_VALUE));

    // now attempt wipe of those blocks if required
    if (!args.getBoolean(ARG_NOWIPE) && !wipeblocks.isEmpty())
    {
        WipeBlocksOp op = new WipeBlocksOp(aic.filePath, aic.getBlockSize(), wipeblocks, true);
        ProgressBar pb = new ProgressBar(120, op.getTotalBlocks(), "Wiping file blocks: ");
        pb.setEnabled(!args.getBoolean(ARG_NOPROGRESS));
        pb.startFresh();
        op.setProgressUpdate(o -> pb.inc(1));
        op.run();
        pb.finish();
        System.out.println(String.format("Wiped %d blocked clean.", op.getBlocksWiped()));
    }
}
 
开发者ID:AstromechZA,项目名称:bunkr,代码行数:31,代码来源:RmCommand.java

示例13: handle

import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
public void handle(Namespace args) throws Exception
{
    try
    {
        UserSecurityProvider usp = new UserSecurityProvider(makeCLIPasswordProvider(args.get(CLI.ARG_PASSWORD_FILE)));

        ArchiveInfoContext aic = new ArchiveInfoContext(args.get(CLI.ARG_ARCHIVE_PATH), usp);
        IFFTraversalTarget target = InventoryPather.traverse(aic.getInventory(), args.getString(ARG_PATH));
        if (!target.isAFile()) throw new CLIException("'%s' is not a file.", args.getString(ARG_PATH));

        FileInventoryItem targetFile = (FileInventoryItem) target;

        File inputFile = args.get(ARG_DESTINATION_FILE);
        boolean checkHash = (!args.getBoolean(ARG_IGNORE_INTEGRITY_CHECK));
        if (inputFile.getPath().equals("-"))
        {
            writeBlockFileToStream(aic, targetFile, System.out, checkHash, false);
        }
        else
        {
            if (inputFile.exists()) throw new CLIException("'%s' already exists. Will not overwrite.", inputFile.getCanonicalPath());
            FileChannel fc = new RandomAccessFile(inputFile, "rw").getChannel();
            try (OutputStream contentOutputStream = Channels.newOutputStream(fc))
            {
                writeBlockFileToStream(aic, targetFile, contentOutputStream, checkHash, !args.getBoolean(ARG_NO_PROGRESS));
            }
        }
    }
    catch (IntegrityHashError e)
    {
        throw new CLIException(e);
    }
}
 
开发者ID:AstromechZA,项目名称:bunkr,代码行数:35,代码来源:ExportFileCommand.java

示例14: getGson

import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
static Gson getGson(final Namespace parsedArgs) {
    final GsonBuilder builder = new GsonBuilder();
    if (parsedArgs.getBoolean("pretty")) {
        builder.setPrettyPrinting();
    }
    return builder.create();
}
 
开发者ID:Glassdoor,项目名称:planout4j,代码行数:8,代码来源:Planout4jTool.java

示例15: main

import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
public static void main(String... args) throws Exception {
    // Start cassandra if necessary (cassandra.yaml is provided)
    ArgumentParser parser = ArgumentParsers.newArgumentParser("java -jar emodb-web-local*.jar");
    parser.addArgument("server").required(true).help("server");
    parser.addArgument("emo-config").required(true).help("config.yaml - EmoDB's config file");
    parser.addArgument("emo-config-ddl").required(true).help("config-ddl.yaml - EmoDB's cassandra schema file");
    parser.addArgument("cassandra-yaml").nargs("?").help("cassandra.yaml - Cassandra configuration file to start an" +
            " in memory embedded Cassandra.");
    parser.addArgument("-z","--zookeeper").dest("zookeeper").action(Arguments.storeTrue()).help("Starts zookeeper");

    // Get the path to cassandraYaml or if zookeeper is available
    Namespace result = parser.parseArgs(args);
    String cassandraYaml = result.getString("cassandra-yaml");
    boolean startZk = result.getBoolean("zookeeper");

    String[] emoServiceArgs = args;

    // Start ZooKeeper
    TestingServer zooKeeperServer = null;
    if (startZk) {
        zooKeeperServer = isLocalZooKeeperRunning() ? null : startLocalZooKeeper();
        emoServiceArgs = (String[]) ArrayUtils.removeElement(args, "-z");
        emoServiceArgs = (String[]) ArrayUtils.removeElement(emoServiceArgs, "--zookeeper");

    }
    boolean success = false;


    if (cassandraYaml != null) {
        // Replace $DIR$ so we can correctly specify location during runtime
        File templateFile = new File(cassandraYaml);
        String baseFile = Files.toString(templateFile, Charset.defaultCharset());
        // Get the jar location
        String path = EmoServiceWithZK.class.getProtectionDomain().getCodeSource().getLocation().getPath();
        String parentDir = new File(path).getParent();
        String newFile = baseFile.replace("$DATADIR$", new File(parentDir, "data").getAbsolutePath());
        newFile = newFile.replace("$COMMITDIR$", new File(parentDir, "commitlog").getAbsolutePath());
        newFile = newFile.replace("$CACHEDIR$", new File(parentDir, "saved_caches").getAbsolutePath());
        File newYamlFile = new File(templateFile.getParent(), "emo-cassandra.yaml");
        Files.write(newFile, newYamlFile, Charset.defaultCharset());

        startLocalCassandra(newYamlFile.getAbsolutePath());
        emoServiceArgs = (String[]) ArrayUtils.removeElement(emoServiceArgs, cassandraYaml);
    }

    try {
        EmoService.main(emoServiceArgs);
        success = true;

    } catch (Throwable t) {
        t.printStackTrace();
    } finally {
        // The main web server command returns immediately--don't stop ZooKeeper/Cassandra in that case.
        if (zooKeeperServer != null && !(success && args.length > 0 && "server".equals(args[0]))) {
            zooKeeperServer.stop();
            service.shutdown();
        }
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:60,代码来源:EmoServiceWithZK.java


注:本文中的net.sourceforge.argparse4j.inf.Namespace.getBoolean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。