Documentation
¶
Index ¶
- Variables
- func AutoCompleteJSON(input string) string
- func DeleteFilePath(path string) error
- func ExpandGlobs(args []string) []string
- func GlobCompletion(prefix string) []string
- func HistorySearch(prefix string) []string
- func JSONResult(r CmdResult) string
- func ListDirEntryJSON(path string) (string, error)
- func ParseRedirects(line string) (string, []string, string, string, string, bool, bool)
- func ReadFileContent(path string) (string, error)
- func RecursiveSync(dir string)
- func ResetHistory()
- func ResolvePath(p string) string
- func SetShellEnv(e *Env)
- func SetStoreWriter(s StoreWriter)
- func SplitPipeline(input string) []string
- func SyncDeleteFile(path string) error
- func SyncWriteFile(path, content string) error
- func Tokenize(line string, keepQuotes bool) []string
- func WriteFileContent(path, content string) error
- type AutoCompleteResult
- type CmdResult
- type CommandFunc
- type DirEntry
- type Env
- type StoreWriter
Constants ¶
This section is empty.
Variables ¶
var BuiltinNames = map[string]bool{ "ls": true, "cd": true, "pwd": true, "cat": true, "mkdir": true, "rm": true, "rmdir": true, "cp": true, "mv": true, "touch": true, "echo": true, "head": true, "tail": true, "wc": true, "grep": true, "sort": true, "find": true, "tree": true, "clear": true, "help": true, "date": true, "whoami": true, "env": true, "export": true, "which": true, "type": true, "history": true, "println": true, "basename": true, "dirname": true, "realpath": true, "tr": true, "uniq": true, "cut": true, "tee": true, }
BuiltinNames lists all built-in command names.
var CmdRegistry = map[string]CommandFunc{}
CmdRegistry maps command names to their implementations.
Functions ¶
func AutoCompleteJSON ¶
AutoCompleteJSON returns completions as a JSON string.
func ExpandGlobs ¶
ExpandGlobs expands glob patterns in arguments.
func GlobCompletion ¶
GlobCompletion returns files matching a glob prefix for tab completion.
func HistorySearch ¶
HistorySearch searches command history for a prefix.
func JSONResult ¶
JSONResult marshals a CmdResult to JSON string.
func ListDirEntryJSON ¶
ListDirEntryJSON returns the JSON representation of directory entries.
func ParseRedirects ¶
ParseRedirects extracts command name, args, and redirect operators from a line. Returns: name, args, stdinFile, stdoutFile, stderrFile, appendStdout, appendStderr
func ReadFileContent ¶
ReadFileContent reads a file and returns its content as a string.
func RecursiveSync ¶
func RecursiveSync(dir string)
RecursiveSync removes deleted files from the store by walking the filesystem. This is a best-effort reconciliation after operations like rm -rf.
func ResetHistory ¶
func ResetHistory()
ResetHistory clears the command history (useful for testing).
func ResolvePath ¶
ResolvePath expands ~ and makes relative paths absolute against cwd.
func SetShellEnv ¶
func SetShellEnv(e *Env)
SetShellEnv replaces the global shell environment (useful for testing).
func SetStoreWriter ¶
func SetStoreWriter(s StoreWriter)
SetStoreWriter sets the StoreWriter used for persisting files.
func SplitPipeline ¶
SplitPipeline splits a command line by unquoted pipe characters.
func SyncDeleteFile ¶
SyncDeleteFile removes a file from the filesystem (MEMFS) and syncs to the StoreWriter.
func SyncWriteFile ¶
SyncWriteFile writes content to the filesystem (MEMFS) and syncs to the StoreWriter.
func WriteFileContent ¶
WriteFileContent writes content to a file.
Types ¶
type AutoCompleteResult ¶
type AutoCompleteResult struct {
Completions []string `json:"completions"`
}
AutoCompleteResult holds the JSON response for tab completion.
func AutoComplete ¶
func AutoComplete(input string) AutoCompleteResult
AutoComplete performs tab completion for the given input. It handles: - Command name completion (first token) - File/directory path completion (subsequent tokens) - History search (for empty input or ! commands)
type CmdResult ¶
type CmdResult struct {
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
ExitCode int `json:"exitCode"`
}
CmdResult holds the result of a command execution.
func ParseAndExecute ¶
ParseAndExecute is the main entry point for executing a command string. It handles pipes, redirects, and dispatches to the appropriate command.
type CommandFunc ¶
CommandFunc is the type for all command implementations.
type DirEntry ¶
type DirEntry struct {
Name string `json:"name"`
Type string `json:"type"` // "file" or "dir"
Size int64 `json:"size"`
Mode uint32 `json:"mode"`
}
DirEntry represents a directory listing entry.
type Env ¶
Env holds the shell environment variables.
var ShellEnv *Env
ShellEnv holds the global shell environment.
type StoreWriter ¶
StoreWriter is the interface for persisting file writes/deletes to external storage. In the WASM build, this is backed by IndexedDB. In tests, a no-op is used.