package p.studio;

import java.util.Optional;

public final class StudioAppInfo {
    private static final String VERSION_PROPERTY = "prometeu.studio.version";
    private static final String FALLBACK_VERSION = "dev";

    private StudioAppInfo() {
    }

    public static String version() {
        final String explicit = System.getProperty(VERSION_PROPERTY);
        if (explicit != null && !explicit.isBlank()) {
            return explicit.trim();
        }

        return Optional.ofNullable(StudioAppInfo.class.getPackage().getImplementationVersion())
                .filter(value -> !value.isBlank())
                .orElse(FALLBACK_VERSION);
    }
}
