Map<String, Object> opts = new Docopt(USAGE) .withVersion(GitRepositoryState.getRepositoryState().describe) .parse(args);
public static void main(String[] args) throws IOException { URL usage = Resources.getResource("usage.docopts.txt"); String doc = Resources.toString(usage, Charset.forName("UTF-8")); Docopt options = new Docopt(doc); Map<String, Object> optMap = options.parse(args);
public static void main(String[] args) { Map<String, Object> params = new Docopt(doc).parse(args); String url = (String)params.get("<url>"); CrawlerConfiguration cfg = new CrawlerConfigurationBuilder(url).withMaxParallelRequests(20).withRequestDelay(500).withLinkNormalizer(new NoAnchorLinkNormalizer(url)).build(); PageCrawler crawler = new PageCrawler(cfg); crawler.crawl(new DownloadMatchingVisitor((String)params.get("--valid-pages"), (String)params.get("--download-pages"), (String)params.get("--output-folder"))); } }
new Docopt(USAGE) .withVersion(GitRepositoryState.getRepositoryState().describe) .parse(args);
/** * boilerplate activity generator, to be invoked from an application's main(). * * @param args are the args passed to main */ void start(String[] args) { // Parse the options given, using docopt. Map<String, Object> opts = new Docopt(USAGE) .withVersion(GitRepositoryState.getRepositoryState().describe) .parse(args); String corfuConfigurationString = (String) opts.get("-c"); /** * Must set up a Corfu runtime before everything. */ setCorfuRuntime( getRuntimeAndConnect(corfuConfigurationString) ); /** * Obviously, this application is not doing much yet, * but you can already invoke getRuntimeAndConnect to test if you can connect to a deployed Corfu service. * * Next, invoke a class-specific activity wrapper named 'action()'. */ action(); }