Package net.sourceforge.argparse4j.inf

Examples of net.sourceforge.argparse4j.inf.Namespace


    @Test
    public void testSubparsersDest() throws ArgumentParserException {
        Subparsers subparsers = ap.addSubparsers().dest("command");
        subparsers.addParser("install").addArgument("--command")
                .setDefault("default");
        Namespace res = ap.parseArgs("install".split(" "));
        assertEquals("install", res.get("command"));
    }
View Full Code Here


            default: return service.div(a, b);
        }
    }

    public static void main(String[] args) throws Exception {
        Namespace parsedArgs = parseCommandLine(args);

        // Load the config.yaml file specified as the first argument (optional).
        CalculatorConfiguration config = loadConfigFile(parsedArgs.getString("config-file"));

        // Connect to ZooKeeper
        CuratorFramework curator = config.getZooKeeperConfiguration().newCurator();
        curator.start();
View Full Code Here

            default: return _service.div(a, b);
        }
    }

    public static void main(String[] args) throws Exception {
        Namespace parsedArgs = parseCommandLine(args);

        // Load the config.yaml file specified as the first argument (optional).
        CalculatorConfiguration config = loadConfigFile(parsedArgs.getString("config-file"));

        // Connect to ZooKeeper
        CuratorFramework curator = config.getZooKeeperConfiguration().newCurator();
        curator.start();
View Full Code Here

            // ignored
        }
    }

    public static void main(String[] args) throws Exception {
        Namespace parsedArgs = parseCommandLine(args);

        // Load the config.yaml file specified as the first argument.
        DictionaryConfiguration config = loadConfigFile(parsedArgs.getString("config-file"));

        CuratorFramework curator = config.getZooKeeperConfiguration().newCurator();
        curator.start();

        // Connection caching is optional, but included here for the sake of demonstration.
        ServiceCachingPolicy cachingPolicy = new ServiceCachingPolicyBuilder()
                .withMaxNumServiceInstances(10)
                .withMaxNumServiceInstancesPerEndPoint(1)
                .withMaxServiceInstanceIdleTime(5, TimeUnit.MINUTES)
                .build();

        // The service is partitioned, but partition filtering is configured by the ServiceFactory in this case
        // when the builder calls its configure() method.
        DictionaryServiceFactory serviceFactory = new DictionaryServiceFactory(config.getHttpClientConfiguration());
        DictionaryService service = ServicePoolBuilder.create(DictionaryService.class)
                .withServiceFactory(serviceFactory)
                .withHostDiscovery(new ZooKeeperHostDiscovery(curator, serviceFactory.getServiceName()))
                .withCachingPolicy(cachingPolicy)
                .buildProxy(new ExponentialBackoffRetry(5, 50, 1000, TimeUnit.MILLISECONDS));

        // If using Yammer Metrics or running in Dropwizard (which includes Yammer Metrics), you may want a health
        // check that pings a service you depend on. This will register a simple check that will confirm the service
        // pool contains at least one healthy end point.
        HealthChecks.register(ContainsHealthyEndPointCheck.forProxy(service, "dictionary-user"));

        DictionaryUser user = new DictionaryUser(service);
        for (String wordFile : parsedArgs.<String>getList("word-file")) {
            user.spellCheck(new File(wordFile));
        }

        ServicePoolProxies.close(service);
        Closeables.closeQuietly(curator);
View Full Code Here

            // ignored
        }
    }

    public static void main(String[] args) throws Exception {
        Namespace parsedArgs = parseCommandLine(args);

        // Load the config.yaml file specified as the first argument.
        DictionaryConfiguration config = loadConfigFile(parsedArgs.getString("config-file"));

        CuratorFramework curator = config.getZooKeeperConfiguration().newCurator();
        curator.start();

        // Connection caching is optional, but included here for the sake of demonstration.
        ServiceCachingPolicy cachingPolicy = new ServiceCachingPolicyBuilder()
                .withMaxNumServiceInstances(10)
                .withMaxNumServiceInstancesPerEndPoint(1)
                .withMaxServiceInstanceIdleTime(5, TimeUnit.MINUTES)
                .build();

        // The service is partitioned, but partition filtering is configured by the ServiceFactory in this case
        // when the builder calls its configure() method.
        DictionaryServiceFactory serviceFactory = new DictionaryServiceFactory(config.getHttpClientConfiguration());
        DictionaryService service = ServicePoolBuilder.create(DictionaryService.class)
                .withServiceFactory(serviceFactory)
                .withHostDiscovery(new ZooKeeperHostDiscovery(curator, serviceFactory.getServiceName()))
                .withCachingPolicy(cachingPolicy)
                .buildProxy(new ExponentialBackoffRetry(5, 50, 1000, TimeUnit.MILLISECONDS));

        // If using Yammer Metrics or running in Dropwizard (which includes Yammer Metrics), you may want a health
        // check that pings a service you depend on. This will register a simple check that will confirm the service
        // pool contains at least one healthy end point.
        HealthChecks.register(new ContainsHealthyEndPointCheck(ServicePoolProxies.getPool(service), "dictionary-user"));

        DictionaryUser user = new DictionaryUser(service);
        for (String wordFile : parsedArgs.<String>getList("word-file")) {
            user.spellCheck(new File(wordFile));
        }

        ServicePoolProxies.close(service);
        Closeables.closeQuietly(curator);
View Full Code Here

                    .type(new PathArgumentType(conf).verifyHasScheme().verifyExists().verifyCanRead())
                    .nargs("*")
                    .setDefault()
                    .help("HDFS URI of file or directory tree to index.");

            Namespace ns;
            try {
                ns = parser.parseArgs(args);
            } catch (FoundHelpArgument e) {
                return 0;
            } catch (ArgumentParserException e) {
                parser.handleError(e);
                return 1;
            }

            opts.log4jConfigFile = (File) ns.get(log4jConfigFileArg.getDest());
            if (opts.log4jConfigFile != null) {
                PropertyConfigurator.configure(opts.log4jConfigFile.getPath());
            }
            LOG.debug("Parsed command line args: {}", ns);

            opts.inputLists = ns.getList(inputListArg.getDest());
            if (opts.inputLists == null) {
                opts.inputLists = Collections.EMPTY_LIST;
            }
            opts.inputFiles = ns.getList(inputFilesArg.getDest());
            opts.outputDir = (Path) ns.get(outputDirArg.getDest());
            opts.mappers = ns.getInt(mappersArg.getDest());
            opts.reducers = ns.getInt(reducersArg.getDest());
            opts.updateConflictResolver = ns.getString(updateConflictResolverArg.getDest());
            opts.fanout = ns.getInt(fanoutArg.getDest());
            opts.maxSegments = ns.getInt(maxSegmentsArg.getDest());
            opts.morphlineFile = (File) ns.get(morphlineFileArg.getDest());
            opts.morphlineId = ns.getString(morphlineIdArg.getDest());
            opts.solrHomeDir = (File) ns.get(solrHomeDirArg.getDest());
            opts.fairSchedulerPool = ns.getString(fairSchedulerPoolArg.getDest());
            opts.isDryRun = ns.getBoolean(dryRunArg.getDest());
            opts.isVerbose = ns.getBoolean(verboseArg.getDest());
            opts.zkHost = ns.getString(zkHostArg.getDest());
            opts.shards = ns.getInt(shardsArg.getDest());
            opts.shardUrls = buildShardUrls(ns.getList(shardUrlsArg.getDest()), opts.shards);
            opts.goLive = ns.getBoolean(goLiveArg.getDest());
            opts.goLiveThreads = ns.getInt(goLiveThreadsArg.getDest());
            opts.collection = ns.getString(collectionArg.getDest());

            try {
                verifyGoLiveArgs(opts, parser);
            } catch (ArgumentParserException e) {
                parser.handleError(e);
View Full Code Here

       
        optionalGroup.addArgument(SHOW_NON_SOLR_CLOUD)
                .action(Arguments.storeTrue())
                .help("Also show options for Non-SolrCloud mode as part of --help.");
   
        Namespace ns;
        try {
            ns = parser.parseArgs(args);
        } catch (FoundHelpArgument e) {
            return 0;
        } catch (ArgumentParserException e) {
            parser.handleError(e);
            return 1;
        }

        opts.log4jConfigFile = (File) ns.get(log4jConfigFileArg.getDest());
        if (opts.log4jConfigFile != null) {
            PropertyConfigurator.configure(opts.log4jConfigFile.getPath());
        }
        LOG.debug("Parsed command line args: " + ns);

        opts.inputLists = Collections.EMPTY_LIST;
        opts.outputDir = (Path) ns.get(outputDirArg.getDest());
        opts.overwriteOutputDir = ns.getBoolean(overwriteOutputDirArg.getDest());
        opts.reducers = ns.getInt(reducersArg.getDest());
        opts.updateConflictResolver = ns.getString(updateConflictResolverArg.getDest());
        opts.fanout = ns.getInt(fanoutArg.getDest());
        opts.maxSegments = ns.getInt(maxSegmentsArg.getDest());
        opts.morphlineFile = (File) ns.get(morphlineFileArg.getDest());
        opts.morphlineId = ns.getString(morphlineIdArg.getDest());
        opts.solrHomeDir = (File) ns.get(solrHomeDirArg.getDest());
        opts.fairSchedulerPool = ns.getString(fairSchedulerPoolArg.getDest());
        opts.isDryRun = ns.getBoolean(dryRunArg.getDest());
        opts.isVerbose = ns.getBoolean(verboseArg.getDest());
        opts.zkHost = ns.getString(zkHostArg.getDest());
        opts.shards = ns.getInt(shardsArg.getDest());
        opts.shardUrls = ForkedMapReduceIndexerTool.buildShardUrls(ns.getList(shardUrlsArg.getDest()), opts.shards);
        opts.goLive = ns.getBoolean(goLiveArg.getDest());
        opts.goLiveThreads = ns.getInt(goLiveThreadsArg.getDest());
        opts.collection = ns.getString(collectionArg.getDest());
        opts.clearIndex = ns.getBoolean(clearIndexArg.getDest());

        opts.hbaseIndexerComponentFactory = (String) ns.get(hbaseIndexerComponentFactoryArg.getDest());
        opts.hbaseIndexerConfigFile = (File) ns.get(hbaseIndexerConfigArg.getDest());
        opts.hbaseIndexerZkHost = ns.getString(indexerZkHostArg.getDest());
        opts.hbaseIndexerName = ns.getString(indexNameArg.getDest());
        opts.hbaseTableName = ns.getString(hbaseTableNameArg.getDest());
        opts.hbaseStartRow = ns.getString(startRowArg.getDest());
        opts.hbaseEndRow = ns.getString(endRowArg.getDest());
        opts.hbaseStartTimeString = ns.getString(startTimeArg.getDest());
        opts.hbaseEndTimeString = ns.getString(endTimeArg.getDest());
        opts.hbaseTimestampFormat = ns.getString(timestampFormatArg.getDest());

        try {
            try {
                opts.evaluate();
            } catch (IllegalStateException ise) {
View Full Code Here

        contentTypes.addArgument("-J", "--json").dest("content_type").setConst("application/json").action(storeConst()).help("Specifies application/json in the Content-Type request header");

        parser.addArgument("url").required(true);

        try {
            Namespace ns = parser.parseArgs(args);
            String method = ns.getString("request");
            String url = ns.getString("url");
            String apiKey = ns.getString("apiKey");
            String secretKey = ns.getString("secretKey");
            String contentType = ns.getString("content_type");
            boolean verbose = ns.getBoolean("verbose");

            byte[] data = getData(ns.getString("data"));

            String payload = run(method, url, apiKey, secretKey, data, contentType, verbose);

            if (payload != null) {
                System.out.println(payload); // TODO: do we want this newline?  may screw up binary data... but do we want to use Strings then?
View Full Code Here

            default: return _service.div(a, b);
        }
    }

    public static void main(String[] args) throws Exception {
        Namespace parsedArgs = parseCommandLine(args);

        // Load the config.yaml file specified as the first argument (optional).
        CalculatorConfiguration config = loadConfigFile(parsedArgs.getString("config-file"));

        // Connect to ZooKeeper
        CuratorFramework curator = config.getZooKeeperConfiguration().newCurator();
        curator.start();
View Full Code Here

            default: return service.div(a, b);
        }
    }

    public static void main(String[] args) throws Exception {
        Namespace parsedArgs = parseCommandLine(args);

        // Load the config.yaml file specified as the first argument (optional).
        CalculatorConfiguration config = loadConfigFile(parsedArgs.getString("config-file"));

        // Connect to ZooKeeper
        CuratorFramework curator = config.getZooKeeperConfiguration().newCurator();
        curator.start();
View Full Code Here

TOP

Related Classes of net.sourceforge.argparse4j.inf.Namespace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.