package spm

import (
	"os/exec"
)

// persistSystemEnvVar sets a persistent environment variable on Windows using the `setx` command.
// Perhaps support for other systems would be needed, but all of this "Launcher" thingy is probably going to end up
// being Windows-specific, as other superior systems have their own package managers.
func persistSystemEnvVar(key, value string) error {
	cmd := exec.Command("cmd", "/C", "setx", key, value)
	err := cmd.Run()
	if err != nil {
		return err
	}
	return nil
}

// IsMatchingEntry checks if a package entry matches the requested specs
func IsMatchingEntry(e AppIndexEntry, name, release, arch, osName, pkgType string) bool {
	return e.Name == name &&
		e.Release == release &&
		e.Arch == arch &&
		e.OS == osName &&
		e.Type == pkgType
}