Newer
Older
KeeperJerry_Launcher / LaunchServer / source / command / hash / HashUpdatesCommand.java
package launchserver.command.hash;

import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import launcher.helper.LogHelper;
import launchserver.LaunchServer;
import launchserver.command.Command;

public final class HashUpdatesCommand extends Command {
	public HashUpdatesCommand(LaunchServer server) {
		super(server);
	}

	@Override
	public String getArgsDescription() {
		return "[subdirs...]";
	}

	@Override
	public String getUsageDescription() {
		return "Rehash updates dir";
	}

	@Override
	public void invoke(String... args) throws IOException {
		Set<String> dirs = null;
		if (args.length > 0) { // Hash all updates dirs
			dirs = new HashSet<>(args.length);
			Collections.addAll(dirs, args);
		}

		// Hash updates dir
		server.hashUpdatesDir(dirs);
		LogHelper.subInfo("Updates dir successfully rehashed");
	}
}