com.sshtools.commands.JadaptiveCommand Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of command-utils Show documentation
Show all versions of command-utils Show documentation
Utility classes for creating SSH enabled commands with Maverick Synergy
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()));
}
}