cmds

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PublishTargets []PublishTarget
	PublishBaseURL string
)

Package-level publish state. Populated by the server at startup via RegisterPublishTarget and PublishBaseURL. See docs/openlore-cli-wart-audit.md (W-01/W-02) for the planned migration onto Shell/CmdContext.

View Source
var Registry = map[string]CmdFunc{}

Registry maps command names to their implementations.

View Source
var Skills []SkillEntry

Skills holds dynamically registered skill commands.

View Source
var VersionString = "unknown"

VersionString is set by the server at init time.

Functions

func CleanPath

func CleanPath(p string) string

CleanPath normalises a path to always start with / and removes . and .. segments.

func CmdAlias

func CmdAlias(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdAwk

func CmdAwk(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdBase64

func CmdBase64(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdBasename

func CmdBasename(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdBracket

func CmdBracket(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdCat

func CmdCat(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdCd

func CmdCd(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdClear

func CmdClear(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdColumn

func CmdColumn(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdComm

func CmdComm(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdCommand

func CmdCommand(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdCut

func CmdCut(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdDate

func CmdDate(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdDiff

func CmdDiff(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdDirname

func CmdDirname(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdDu

func CmdDu(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdEcho

func CmdEcho(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdEnv

func CmdEnv(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdEval

func CmdEval(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdExpand

func CmdExpand(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdExport

func CmdExport(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdExpr

func CmdExpr(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdFalse

func CmdFalse(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdFind

func CmdFind(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdFold

func CmdFold(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdGrep

func CmdGrep(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdHead

func CmdHead(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdHelp

func CmdHelp(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdHistory

func CmdHistory(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdHostname

func CmdHostname(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdJoin

func CmdJoin(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdJq

func CmdJq(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdLs

func CmdLs(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdMd5sum

func CmdMd5sum(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdNl

func CmdNl(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdPaste

func CmdPaste(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdPrintenv

func CmdPrintenv(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdPrintf

func CmdPrintf(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdPublish

func CmdPublish(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

CmdPublish writes stdin to a file inside a writable docset. The session's writable docsets are supplied via the OPENLORE_DOCSETS env var (set by the server from the identity's `publish` list). Writes are whole-file: the command buffers stdin and writes once.

func CmdRead

func CmdRead(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdRev

func CmdRev(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdSed

func CmdSed(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdSeq

func CmdSeq(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdSet

func CmdSet(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdSha1sum

func CmdSha1sum(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdSha256sum

func CmdSha256sum(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdSkills

func CmdSkills(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

CmdSkills lists all available skills.

func CmdSleep

func CmdSleep(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdSort

func CmdSort(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdSource

func CmdSource(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdStat

func CmdStat(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdTac

func CmdTac(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdTail

func CmdTail(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdTee

func CmdTee(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdTest

func CmdTest(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdTime

func CmdTime(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdTimeout

func CmdTimeout(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdTr

func CmdTr(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdTree

func CmdTree(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdTrue

func CmdTrue(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdType

func CmdType(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdUnalias

func CmdUnalias(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdUnexpand

func CmdUnexpand(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdUniq

func CmdUniq(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdUnset

func CmdUnset(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdVersion

func CmdVersion(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

CmdVersion prints the OpenLore version.

func CmdWc

func CmdWc(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdWhich

func CmdWhich(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdWhoami

func CmdWhoami(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func CmdXargs

func CmdXargs(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

func IsKnown

func IsKnown(name string) bool

IsKnown returns true if the command name is registered.

func PrintLong

func PrintLong(w io.Writer, f *FileInfo)

PrintLong prints a file in long format (used by ls -l).

func ReadInputLines

func ReadInputLines(ctx CmdContext, files []string, stdin io.Reader, errW io.Writer, cmdName string) ([]string, int)

ReadInputLines reads lines from files or stdin, used by many text commands.

func Register

func Register(name string, fn CmdFunc)

Register adds a command to the registry.

func RegisterPublishTarget

func RegisterPublishTarget(name, diskDir string, maxFileSize int64)

RegisterPublishTarget registers a writable docset. Append-only.

func RegisterSkill

func RegisterSkill(name, description, content string)

RegisterSkill adds a skill as a shell command.

func WalkDir

func WalkDir(fsys FileSystem, root string, fn func(path string, info *FileInfo, err error) error) error

WalkDir walks the filesystem tree rooted at root, calling fn for each file or directory.

Types

type CmdContext

type CmdContext interface {
	FS() FileSystem
	Cwd() string
	SetCwd(dir string)
	Resolve(path string) string
	GetEnv(key string) string
	SetEnv(key, value string)
	DeleteEnv(key string)
	AllEnv() map[string]string
	Exec(cmdLine string, w io.Writer, errW io.Writer, stdin io.Reader) int
	ExecPipeline(line string, w io.Writer, errW io.Writer, stdin io.Reader) int
}

CmdContext provides the interface that commands use to interact with the shell. Implemented by bashfs.Shell.

type CmdFunc

type CmdFunc func(ctx CmdContext, args []string, w io.Writer, errW io.Writer, stdin io.Reader) int

CmdFunc is the signature for all shell commands.

type FileInfo

type FileInfo struct {
	FileName    string
	FilePath    string
	Content     []byte
	Dir         bool
	FileModTime time.Time
	FileSize    int64
}

FileInfo represents a file or directory in the virtual filesystem.

func (*FileInfo) IsDir

func (fi *FileInfo) IsDir() bool

func (*FileInfo) ModTime

func (fi *FileInfo) ModTime() time.Time

func (*FileInfo) Mode

func (fi *FileInfo) Mode() fs.FileMode

func (*FileInfo) Name

func (fi *FileInfo) Name() string

func (*FileInfo) Size

func (fi *FileInfo) Size() int64

func (*FileInfo) Sys

func (fi *FileInfo) Sys() interface{}

type FileSystem

type FileSystem interface {
	Stat(path string) (*FileInfo, error)
	ReadDir(path string) ([]FileInfo, error)
	ReadFile(path string) ([]byte, error)
}

FileSystem is the read-only filesystem interface that all commands operate on.

type PublishTarget

type PublishTarget struct {
	Name        string
	DiskDir     string
	MaxFileSize int64
}

PublishTarget is a writable docset: its logical name (the first path segment used in `publish /<name>/<file>`) mapped to an on-disk directory.

type SkillEntry

type SkillEntry struct {
	Name        string
	Description string
	Content     string
}

SkillEntry is a registered skill command.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL