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

com.aeontronix.enhancedmule.tools.ocli.OCliClient Maven / Gradle / Ivy

There is a newer version: 2.0.0-alpha4
Show newest version
/*
 * Copyright (c) Aeontronix 2019
 */

package com.aeontronix.enhancedmule.tools.ocli;

import java.io.File;

/**
 * This class allows to use the official anypoint cli tool
 */
public class OCliClient {
    private final String executableOnPath;

    /**
     * @throws IllegalStateException if anypoint cli is not found in path
     */
    public OCliClient() {
        executableOnPath = findExecutableOnPath("anypoint-cli");
    }

    public OCliClient(String executableOnPath) {
        this.executableOnPath = executableOnPath;
    }

    public static String findExecutableOnPath(String name) {
        for (String dirname : System.getenv("PATH").split(File.pathSeparator)) {
            File file = new File(dirname, name);
            if (file.isFile() && file.canExecute()) {
                return file.getAbsolutePath();
            }
        }
        throw new IllegalStateException("anypoint-cli executable not found in path");
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy