builtins

package
v0.0.0-...-15f74bb Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package builtins implements the DOS built-in command registry.

Index

Constants

View Source
const EchoStateKey = "_ECHO"

EchoStateKey is the env key used to persist ECHO ON/OFF state.

Variables

This section is empty.

Functions

func DriveSwitch

func DriveSwitch(drive string, dm *fsmap.DriveMap, stderr io.Writer) int

DriveSwitch changes the active drive. Called by the exec layer when the command token matches the pattern ^[A-Z]:$.

func RegisterAll

func RegisterAll(r *Registry, ver string)

RegisterAll registers every built-in command with r. ver is the version string printed by VER.

Types

type BuiltinFunc

type BuiltinFunc func(
	args []string,
	e *env.Env,
	dm *fsmap.DriveMap,
	in io.Reader,
	stdout, stderr io.Writer,
) (int, error)

BuiltinFunc is the signature for a built-in command handler.

  • in: stdin (may be nil for commands that don't read it)
  • stdout: normal output
  • stderr: error/diagnostic output

Returns an ERRORLEVEL value (0 = success).

type Registry

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

Registry maps command names (uppercase) to their handlers.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty Registry.

func (*Registry) Describe

func (r *Registry) Describe(name string) (desc, usage string, ok bool)

Describe returns the description and usage for name, if registered.

func (*Registry) Lookup

func (r *Registry) Lookup(name string) (BuiltinFunc, bool)

Lookup returns the handler for name, if any.

func (*Registry) Names

func (r *Registry) Names() []string

Names returns all registered command names.

func (*Registry) Register

func (r *Registry) Register(name, desc, usage string, fn BuiltinFunc)

Register adds a builtin under the given name (stored uppercase). desc is a one-line description; usage is a short synopsis (may be "").

Jump to

Keyboard shortcuts

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