package env

import (
	
	
	
	

	
)

const (
	CARAPACE_COMPLINE      = "CARAPACE_COMPLINE"      // TODO
	CARAPACE_COVERDIR      = "CARAPACE_COVERDIR"      // coverage directory for sandbox tests
	CARAPACE_EXPERIMENTAL  = "CARAPACE_EXPERIMENTAL"  // enable experimental features
	CARAPACE_HIDDEN        = "CARAPACE_HIDDEN"        // show hidden commands/flags
	CARAPACE_LENIENT       = "CARAPACE_LENIENT"       // allow unknown flags
	CARAPACE_LOG           = "CARAPACE_LOG"           // enable logging
	CARAPACE_MATCH         = "CARAPACE_MATCH"         // match case insensitive
	CARAPACE_NOSPACE       = "CARAPACE_NOSPACE"       // nospace suffixes
	CARAPACE_SANDBOX       = "CARAPACE_SANDBOX"       // mock context for sandbox tests
	CARAPACE_TOOLTIP       = "CARAPACE_TOOLTIP"       // enable tooltip style
	CARAPACE_UNFILTERED    = "CARAPACE_UNFILTERED"    // skip the final filtering step
	CARAPACE_ZSH_HASH_DIRS = "CARAPACE_ZSH_HASH_DIRS" // zsh hash directories
	CLICOLOR               = "CLICOLOR"               // disable color
	NO_COLOR               = "NO_COLOR"               // disable color
)

func () bool {
	return getBool(NO_COLOR) || os.Getenv(CLICOLOR) == "0"
}

func () bool {
	return getBool(CARAPACE_EXPERIMENTAL)
}

func () bool {
	return getBool(CARAPACE_LENIENT)
}

func () string {
	return os.Getenv(CARAPACE_ZSH_HASH_DIRS)
}

func () ( *common.Mock,  error) {
	 := os.Getenv(CARAPACE_SANDBOX)
	if  == "" || !isGoRun() {
		return nil, errors.New("no sandbox")
	}

	 = json.Unmarshal([]byte(), &)
	return
}

func () bool {
	return getBool(CARAPACE_LOG)
}

func () bool {
	return getBool(CARAPACE_HIDDEN)
}

func () string {
	return os.Getenv(CARAPACE_COVERDIR) // custom env for GOCOVERDIR so that it works together with `-coverprofile`
}

func isGoRun() bool { return strings.HasPrefix(os.Args[0], os.TempDir()+"/go-build") }

func () string { // see match.Match
	return os.Getenv(CARAPACE_MATCH)
}

func () string {
	return os.Getenv(CARAPACE_NOSPACE)
}

func () bool {
	return getBool(CARAPACE_TOOLTIP)
}

func () string {
	return os.Getenv(CARAPACE_COMPLINE)
}

func () bool {
	return getBool(CARAPACE_UNFILTERED)
}

func getBool( string) bool {
	switch os.Getenv() {
	case "true", "1":
		return true
	default:
		return false
	}
}