return 0;
}
@Override
public PluginOperationOptions parseOptions(String[] operationArgs) throws Exception {
PluginOperationOptions operationOptions = new PluginOperationOptions();
OptionParser parser = new OptionParser();
OptionSpec<Void> optionLocal = parser.acceptsAll(asList("L", "local-only"));
OptionSpec<Void> optionRemote = parser.acceptsAll(asList("R", "remote-only"));
OptionSpec<Void> optionSnapshots = parser.acceptsAll(asList("s", "snapshot", "snapshots"));
OptionSet options = parser.parse(operationArgs);
// Files
List<?> nonOptionArgs = options.nonOptionArguments();
if (nonOptionArgs.size() == 0) {
throw new Exception("Invalid syntax, please specify an action (list, install, remove).");
}
// <action>
String actionStr = nonOptionArgs.get(0).toString();
action = parsePluginAction(actionStr);
operationOptions.setAction(action);
// --snapshots
operationOptions.setSnapshots(options.has(optionSnapshots));
// install|remove <plugin-id>
if (action == PluginAction.INSTALL || action == PluginAction.REMOVE) {
if (nonOptionArgs.size() != 2) {
throw new Exception("Invalid syntax, please specify a plugin ID.");
}
// <plugin-id>
String pluginId = nonOptionArgs.get(1).toString();
operationOptions.setPluginId(pluginId);
}
// --local-only, --remote-only
else if (action == PluginAction.LIST) {
if (options.has(optionLocal)) {
operationOptions.setListMode(PluginListMode.LOCAL);
}
else if (options.has(optionRemote)) {
operationOptions.setListMode(PluginListMode.REMOTE);
}
else {
operationOptions.setListMode(PluginListMode.ALL);
}
// <plugin-id> (optional in 'list')
if (nonOptionArgs.size() == 2) {
String pluginId = nonOptionArgs.get(1).toString();
operationOptions.setPluginId(pluginId);
}
}
return operationOptions;
}