0
我已经在java中编写了一个CLIInterface,它将来自用户的必要标志作为String []。将参数作为参数运行CLI作为参数的参数
下面是一些示例代码:
public static void call(String[] args)
{
try
{
Map<String, Object> cliOptions = new HashMap<>();
for (int i = 0; i < args.length; ++i) {
// override the db directory
if (args[i].equals("--help")) {
printHelp();
System.exit(1);
}
..........
}
我知道,你可以使用像这样调用该方法在命令行:
的Java -Dexec.mainClass = org.bitcoinj.examples。 ForwardingService -Dexec.args =“”
,但我希望能够使用它像一个CLI和有这样的事情:
ethj - 其中--help会是args [0],然后从那里我可以在调用方法中处理它。
怎么会这样做呢?