From 625e992c9146eb2ac931718eb90cf3fd50cec73f Mon Sep 17 00:00:00 2001 From: zzz Date: Wed, 23 Nov 2016 14:06:33 +0000 Subject: [PATCH] News: Add command line support --- apps/routerconsole/java/build.xml | 1 + .../src/net/i2p/router/news/CommandLine.java | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 apps/routerconsole/java/src/net/i2p/router/news/CommandLine.java diff --git a/apps/routerconsole/java/build.xml b/apps/routerconsole/java/build.xml index 522ee06a76..a2a1878dc8 100644 --- a/apps/routerconsole/java/build.xml +++ b/apps/routerconsole/java/build.xml @@ -129,6 +129,7 @@ + diff --git a/apps/routerconsole/java/src/net/i2p/router/news/CommandLine.java b/apps/routerconsole/java/src/net/i2p/router/news/CommandLine.java new file mode 100644 index 0000000000..5969a84302 --- /dev/null +++ b/apps/routerconsole/java/src/net/i2p/router/news/CommandLine.java @@ -0,0 +1,42 @@ +package net.i2p.router.news; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import net.i2p.router.RouterVersion; + +/** + * Simple command line access to various utilities. + * Not a public API. Subject to change. + * Apps and plugins should use specific classes. + * + * @since 0.9.28 + */ +public class CommandLine extends net.i2p.router.CommandLine { + + protected static final List NCLASSES = Arrays.asList(new String[] { + "net.i2p.router.news.BlocklistEntries", + "net.i2p.router.news.NewsXMLParser" + }); + + protected CommandLine() {} + + public static void main(String args[]) { + List classes = new ArrayList(NCLASSES.size() + RCLASSES.size() + CLASSES.size()); + classes.addAll(NCLASSES); + classes.addAll(RCLASSES); + classes.addAll(CLASSES); + if (args.length > 0) { + exec(args, classes); + } + usage(classes); + System.exit(1); + } + + private static void usage(List classes) { + System.err.println("I2P Router Console version " + RouterVersion.FULL_VERSION + '\n' + + "USAGE: java -jar /path/to/routerconsole.jar command [args]"); + printCommands(classes); + } +}