// nest is the official CLI companion of Parrot Security Linux. See AGENTS.md.
package main

import (
	"os"

	"nest/src/catalog"
	"nest/src/cmd"
	"nest/src/config"
)

// version is injected at link time (AGENTS.md §7); "dev" otherwise.
var version = "dev"

func main() {
	getenv := os.Getenv
	system, user := config.DefaultPaths(getenv)
	app := &cmd.App{
		Stdout:       os.Stdout,
		Stderr:       os.Stderr,
		Stdin:        os.Stdin,
		StdinTTY:     isTerminal(os.Stdin),
		Getenv:       getenv,
		Version:      version,
		CatalogLocs:  catalog.DefaultLocations(getenv),
		ConfigSystem: system,
		ConfigUser:   user,
	}
	os.Exit(app.Run(os.Args[1:]))
}

func isTerminal(f *os.File) bool {
	st, err := f.Stat()
	return err == nil && st.Mode()&os.ModeCharDevice != 0
}
