package installer

import (
	"context"
	"net/http"
	"os"
	"path/filepath"
)

// CommandExecutor defines the interface for executing shell commands
type CommandExecutor interface {
	RunCommand(name string, args ...string) error
	RunShellCommand(script string) error
	RunCommands(commands []string) error
	Context() context.Context
	SetContext(ctx context.Context)
	IsCancelled() bool
	CheckCancelled() error
}

// FileSystem defines the interface for file system operations
type FileSystem interface {
	Exists(path string) bool
	IsDir(path string) bool
	MkdirAll(path string, perm os.FileMode) error
	MkdirTemp(dir, prefix string) (string, error)
	ReadFile(path string) ([]byte, error)
	WriteFile(path string, data []byte, perm os.FileMode) error
	Remove(path string) error
	RemoveAll(path string) error
	Rename(oldPath, newPath string) error
	CopyFile(src, dst string, perm os.FileMode) error
	CopyDir(src, dst string) error
	Stat(path string) (os.FileInfo, error)
	Walk(root string, walkFn filepath.WalkFunc) error
	Glob(pattern string) ([]string, error)
}

// HTTPClient defines the interface for HTTP operations
type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

// Downloader defines the interface for downloading files
type Downloader interface {
	DownloadFile(ctx context.Context, url, dest string, progress func(int64, int64)) error
}

// ArchiveExtractor defines the interface for extracting archives
type ArchiveExtractor interface {
	Extract(ctx context.Context, src, dest string) error
	SupportedFormats() []string
}

// OutputWriter defines the interface for writing output
type OutputWriter interface {
	WriteOutput(msg string)
	WriteError(err error)
}
