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

io.github.laskowski.shell.script.DefaultScriptInfoProvider Maven / Gradle / Ivy

Go to download

Library to launch .bat and .sh scripts of your choice with different configurations. Allows you to read tasks and services output from terminal

There is a newer version: 2.0.6.1
Show newest version
package io.github.laskowski.shell.script;

import io.github.laskowski.os.DefaultOperatingSystemDiscoveryStrategy;
import io.github.laskowski.os.OperatingSystem;
import io.github.laskowski.os.OperatingSystemDiscoveryStrategy;
import io.github.laskowski.shell.DefaultLinuxShellArguments;
import io.github.laskowski.shell.DefaultWindowsShellArguments;
import io.github.laskowski.shell.ShellArguments;

import java.io.File;

public class DefaultScriptInfoProvider implements ScriptInfoProvider {
    private static DefaultScriptInfoProvider instance;

    private DefaultScriptInfoProvider() {}

    public static DefaultScriptInfoProvider getInstance() {
        if (instance == null) {
            instance = new DefaultScriptInfoProvider();
        }

        return instance;
    }

    @Override
    public OperatingSystemDiscoveryStrategy getOperatingSystemDiscoveryStrategy() {
        return DefaultOperatingSystemDiscoveryStrategy.getInstance();
    }

    public ShellArguments getShellArguments() {
        OperatingSystemDiscoveryStrategy operatingSystemDiscoveryStrategy = getOperatingSystemDiscoveryStrategy();
        OperatingSystem operatingSystem = operatingSystemDiscoveryStrategy.getOS();
        switch (operatingSystem) {
            case WINDOWS: return new DefaultWindowsShellArguments();
            case MAC:
            case UNIX: return new DefaultLinuxShellArguments();
            default: throw new IllegalArgumentException("Cannot discover shell arguments for OS: " + operatingSystem);
        }
    }

    public File getScriptDirectory() {
        return new File("shell-scripts");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy