Documentation
¶
Index ¶
- func CopyDir(src, dst string) error
- func DeleteDirFiles(dir string) error
- func DeleteFile(path string) error
- func EnsureDir(path string) error
- func GetUserHomeDir() (string, error)
- func HasWSL() bool
- func HideConsole(*exec.Cmd)
- func OpenDirectory(path string) error
- func OpenPath(path string) error
- func OpenTerminalWithCommand(args ...string) error
- func OpenURL(url string) error
- func PickDirectoryInWSL() (string, error)
- func RunHostStream(ctx context.Context, opts HostExecOptions, onLine HostLineHandler) (int, error)
- type HostExecOptions
- type HostLineHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteDirFiles ¶
DeleteDirFiles deletes all files in the specified directory.
func EnsureDir ¶
EnsureDir checks if a directory exists at the given path. If it does not exist, it creates the directory.
func GetUserHomeDir ¶
GetUserHomeDir returns the user's home directory. On Windows, it handles WSL paths correctly.
func HideConsole ¶
HideConsole is a no-op outside Windows. See exec_windows.go for the Windows implementation that suppresses the transient console window.
func OpenDirectory ¶
OpenDirectory opens the specified directory in the system's file explorer.
func OpenPath ¶
OpenPath opens a local file in the user's default editor / viewer for that file type. Distinct from OpenURL because the WSL path needs a wslpath translation before cmd.exe can hand it off.
func OpenTerminalWithCommand ¶
OpenTerminalWithCommand opens a terminal emulator running the given command.
func PickDirectoryInWSL ¶
PickDirectoryInWSL opens a directory picker dialog inside WSL using zenity. Returns the selected Linux path (e.g., /home/user/projects).
func RunHostStream ¶
func RunHostStream(ctx context.Context, opts HostExecOptions, onLine HostLineHandler) (int, error)
RunHostStream executes a command on the host shell, streaming stdout and stderr line-by-line through onLine. It blocks until the command exits or ctx is cancelled. Returns the exit code (or -1 if the process never started) and an error for plumbing failures only — a non-zero exit is not returned as an error.
On Unix and inside WSL, the command runs under `bash -c`. On native Windows, it runs under `cmd /C`. WSL detection is automatic: a Linux process running inside WSL takes the bash branch.
Types ¶
type HostExecOptions ¶
type HostExecOptions struct {
// Command is a single shell-evaluated command line. It is passed to
// `bash -c` on Unix/WSL or `cmd /C` on native Windows so the user can
// use pipes, redirections, and ${VAR} expansion. Required.
Command string
// Cwd is the working directory the command runs in. Empty inherits the
// parent process's cwd.
Cwd string
// Env is a list of "KEY=VALUE" strings prepended to the inherited
// environment. Later entries override earlier ones (Go's os/exec
// semantics).
Env []string
}
HostExecOptions configures a host-shell command execution.
type HostLineHandler ¶
HostLineHandler receives a single line of stdout (stderr=false) or stderr (stderr=true) from a streaming host command. The trailing newline is stripped. The handler must be cheap; it runs on the streaming goroutine.