Search in sources :

Example 1 with Server

use of bio.terra.cli.businessobject.Server in project terra-cli by DataBiosphere.

the class Set method execute.

/**
 * Update the Terra environment to which the CLI is pointing.
 */
@Override
protected void execute() {
    String prevServerName = Context.getServer().getName();
    Server newServer = Server.get(name);
    boolean serverChanged = !prevServerName.equals(newServer.getName());
    boolean loggedIn = Context.getUser().isPresent();
    boolean workspaceSet = Context.getWorkspace().isPresent();
    if (serverChanged && (loggedIn || workspaceSet)) {
        confirmationPromptOption.confirmOrThrow("Switching the server will clear the current login credentials and workspace. Are you sure you want to proceed (y/N)?", "Switching server aborted.");
    }
    // unset the current user and workspace
    if (loggedIn) {
        Context.requireUser().logout();
    }
    if (workspaceSet) {
        Context.setWorkspace(null);
    }
    Context.setServer(newServer);
    OUT.println("Terra server is set to " + Context.getServer().getName() + " (" + (serverChanged ? "CHANGED" : "UNCHANGED") + ").");
}
Also used : Server(bio.terra.cli.businessobject.Server)

Example 2 with Server

use of bio.terra.cli.businessobject.Server in project terra-cli by DataBiosphere.

the class Status method printText.

/**
 * Print this command's output in text format.
 */
private void printText(String returnValue) {
    Server server = Context.getServer();
    OUT.println("Current server: " + server.getName() + " (" + server.getDescription() + ")");
    OUT.println("Server status: " + returnValue);
}
Also used : Server(bio.terra.cli.businessobject.Server)

Example 3 with Server

use of bio.terra.cli.businessobject.Server in project terra-cli by DataBiosphere.

the class List method printText.

/**
 * Print this command's output in text format.
 */
private void printText(java.util.List<UFServer> returnValue) {
    Server currentServer = Context.getServer();
    TablePrinter<UFServer> printer = Columns::values;
    // print the UFServers, and highlight the current one
    String text = printer.print(returnValue, s -> currentServer.getName().equals(s.name));
    OUT.println(text);
}
Also used : UFServer(bio.terra.cli.serialization.userfacing.UFServer) Server(bio.terra.cli.businessobject.Server) UFServer(bio.terra.cli.serialization.userfacing.UFServer)

Aggregations

Server (bio.terra.cli.businessobject.Server)3 UFServer (bio.terra.cli.serialization.userfacing.UFServer)1