shell

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SplitArgs

func SplitArgs(line string) []string

SplitArgs splits a command line into args, respecting single and double quotes.

Types

type InteractiveOptions added in v0.6.0

type InteractiveOptions struct {
	Width        int
	WidthChanges <-chan int
}

InteractiveOptions describes terminal properties used by the interactive shell. WidthChanges may be nil. Non-positive widths use an 80-column fallback.

type Shell

type Shell struct {
	// contains filtered or unexported fields
}

Shell is a restricted bash-like shell that operates over any vfs.FileSystem.

func NewShell

func NewShell(fs vfs.FileSystem) *Shell

NewShell creates a new Shell backed by the given vfs.FileSystem.

func (*Shell) ActionAllowed

func (s *Shell) ActionAllowed(a cmds.Action) bool

ActionAllowed reports whether the session may perform the capability class. An unrestricted shell (allowedActions == nil) permits everything.

func (*Shell) AllEnv

func (s *Shell) AllEnv() map[string]string

func (*Shell) CommandAttribution added in v0.5.0

func (s *Shell) CommandAttribution() cmds.JobAttribution

func (*Shell) ConfigReloadBackend added in v0.5.0

func (s *Shell) ConfigReloadBackend() cmds.ConfigReloadBackend

func (*Shell) Cwd

func (s *Shell) Cwd() string

func (*Shell) DeleteEnv

func (s *Shell) DeleteEnv(key string)

func (*Shell) Docsets

func (s *Shell) Docsets() []cmds.DocsetInfo

Docsets reports the per-session docset views. Implements CmdContext.

func (*Shell) Exec

func (s *Shell) Exec(cmdLine string, w io.Writer, errW io.Writer, stdin io.Reader) int

Exec parses and executes a single command line.

func (*Shell) ExecPipeline

func (s *Shell) ExecPipeline(line string, w io.Writer, errW io.Writer, stdin io.Reader) int

ExecPipeline parses a shell line and executes the resulting AST. stdin is optional — pass nil if no external stdin is available.

func (*Shell) FS

func (s *Shell) FS() vfs.FileSystem

func (*Shell) GetEnv

func (s *Shell) GetEnv(key string) string

func (*Shell) HistoryBackend added in v0.5.0

func (s *Shell) HistoryBackend() cmds.HistoryBackend

func (*Shell) JobBackend added in v0.5.0

func (s *Shell) JobBackend() cmds.JobBackend

func (*Shell) MetaExtenders added in v0.3.0

func (s *Shell) MetaExtenders() []meta.Extender

MetaExtenders reports the per-session `lore meta` extenders. Implements CmdContext.

func (*Shell) MetaFilters added in v0.3.0

func (s *Shell) MetaFilters() []meta.Filter

func (*Shell) PublishTargets

func (s *Shell) PublishTargets() []cmds.PublishTarget

PublishTargets reports the per-session publish inboxes. Implements CmdContext.

func (*Shell) Resolve

func (s *Shell) Resolve(p string) string

func (*Shell) RunInteractive

func (s *Shell) RunInteractive(rw io.ReadWriter, errW io.Writer, motd string, prompt string)

RunInteractive runs an interactive shell session with an 80-column terminal.

func (*Shell) RunInteractiveWithOptions added in v0.6.0

func (s *Shell) RunInteractiveWithOptions(rw io.ReadWriter, errW io.Writer, motd string, prompt string, opts InteractiveOptions)

RunInteractiveWithOptions runs an interactive shell session. rw is used for both reading input and writing output. When running over an SSH session with an allocated PTY, the session's ptyWriter already converts \n to \r\n, so no additional CRLFWriter wrapping is needed.

func (*Shell) SetActionAuthorizer added in v0.3.0

func (s *Shell) SetActionAuthorizer(fn func(cmds.Action) bool)

SetActionAuthorizer installs a per-invocation narrowing check.

func (*Shell) SetAllowedActions

func (s *Shell) SetAllowedActions(actions []cmds.Action)

SetAllowedActions restricts the shell to the given capability classes (Part B). Passing nil (or not calling this) leaves the shell unrestricted. ActionRead is always implied so that read-only commands and introspection (help, ls, …) keep working.

func (*Shell) SetCommandAttribution added in v0.5.0

func (s *Shell) SetCommandAttribution(a cmds.JobAttribution)

func (*Shell) SetConfigReloadBackend added in v0.5.0

func (s *Shell) SetConfigReloadBackend(b cmds.ConfigReloadBackend)

func (*Shell) SetConflictPolicyFn

func (s *Shell) SetConflictPolicyFn(fn func(resolvedPath string) vfs.WriteConflictPolicy)

SetConflictPolicyFn installs a resolver that maps a resolved path to its write-conflict policy. Passing nil restores the default (vfs.PolicyHash).

func (*Shell) SetCwd

func (s *Shell) SetCwd(dir string)

func (*Shell) SetDocsets

func (s *Shell) SetDocsets(d []cmds.DocsetInfo)

SetDocsets installs the per-session docset views surfaced by `lore docsets`.

func (*Shell) SetEnv

func (s *Shell) SetEnv(key, value string)

func (*Shell) SetHistoryBackend added in v0.5.0

func (s *Shell) SetHistoryBackend(b cmds.HistoryBackend)

func (*Shell) SetJobBackend added in v0.5.0

func (s *Shell) SetJobBackend(b cmds.JobBackend)

func (*Shell) SetMetaExtenders added in v0.3.0

func (s *Shell) SetMetaExtenders(e []meta.Extender)

SetMetaExtenders installs the plugin-contributed extenders applied by `lore meta`.

func (*Shell) SetMetaFilters added in v0.3.0

func (s *Shell) SetMetaFilters(f []meta.Filter)

func (*Shell) SetPublishTargets

func (s *Shell) SetPublishTargets(t []cmds.PublishTarget)

SetPublishTargets installs the per-session publish inboxes used by `publish`.

func (*Shell) SetSizeBackend added in v0.6.0

func (s *Shell) SetSizeBackend(b cmds.SizeBackend)

func (*Shell) SetSkillsManagementEnabled added in v0.4.0

func (s *Shell) SetSkillsManagementEnabled(enabled bool)

func (*Shell) SetSkillsRemoteConfig added in v0.4.0

func (s *Shell) SetSkillsRemoteConfig(timeout time.Duration, maxBytes int64)

func (*Shell) SetUnsupportedUsageHandler added in v0.5.0

func (s *Shell) SetUnsupportedUsageHandler(handler func(UnsupportedUsage))

SetUnsupportedUsageHandler installs optional telemetry for unsupported shell usage. It does not change command output or exit status.

func (*Shell) SetValidators added in v0.3.0

func (s *Shell) SetValidators(validators []validation.Validator)

SetValidators installs plugin-contributed checks for `lore validate`.

func (*Shell) SizeBackend added in v0.6.0

func (s *Shell) SizeBackend() cmds.SizeBackend

func (*Shell) SkillsManagementEnabled added in v0.4.0

func (s *Shell) SkillsManagementEnabled() bool

func (*Shell) SkillsRemoteMaxBytes added in v0.4.0

func (s *Shell) SkillsRemoteMaxBytes() int64

func (*Shell) SkillsRemoteTimeout added in v0.4.0

func (s *Shell) SkillsRemoteTimeout() time.Duration

func (*Shell) Validators added in v0.3.0

func (s *Shell) Validators() []validation.Validator

Validators reports this shell's plugin-contributed validation checks.

func (*Shell) WriteConflictPolicy

func (s *Shell) WriteConflictPolicy(resolvedPath string) vfs.WriteConflictPolicy

WriteConflictPolicy reports the policy for overwrites to resolvedPath. With no resolver installed it returns the default compare-and-swap policy.

type UnsupportedUsage added in v0.5.0

type UnsupportedUsage struct {
	Kind    string
	Command string
	Syntax  string
	Error   string
}

UnsupportedUsage describes a command or shell syntax that OpenLore does not understand. Command is set for unknown commands; Syntax and Error are set for parse failures.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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