All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sshtools.commands.JadaptiveCommand Maven / Gradle / Ivy

The newest version!
package com.sshtools.commands;

import java.text.MessageFormat;
import java.util.concurrent.ScheduledExecutorService;
import java.util.prefs.Preferences;

import com.sshtools.jaul.UpdateService;
import com.sshtools.sequins.Terminal;

import picocli.CommandLine.Model.CommandSpec;

public interface JadaptiveCommand {

	boolean isVerboseExceptions();

	Preferences getPreferences();

	Terminal getTerminal();

	UpdateService getUpdateService();

	ScheduledExecutorService getScheduler();

	String getVersion();

	@SuppressWarnings("unchecked")
	static  C getRootCommand(CommandSpec spec) {
		var cmd = spec.root().userObject();
		if (cmd instanceof SshCommand)
			return (C) cmd;
		else if (cmd instanceof InteractiveSshCommand) {
			return ((InteractiveSshCommand) cmd).rootCommand();
		} else
			throw new UnsupportedOperationException(MessageFormat.format("Root command must either be a {0} or a {1}",
					SshCommand.class.getName(), InteractiveSshCommand.class.getName()));
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy