Documentation
¶
Overview ¶
Package nushell runs a notebook's code cells: each is a nushell pipeline run by `nu` as a separate process, reading other cells' outputs and ranges of sheets as variables ($sales, $selection), and printing what it made as NUON, which the notebook keeps as the cell's output. Tables reach nu as NUON in files it opens, never as text spliced into the pipeline. The package knows neither the terminal nor the notebook: the UI hands it a Job and gets back NUON.
Index ¶
- Constants
- Variables
- func AtLeast(v, oldest string) bool
- func Commands(ctx context.Context, r Runner, timeout time.Duration) ([]string, error)
- func Complete(ctx context.Context, r Runner, script string, offset int) ([]string, error)
- func Exec(ctx context.Context, r Runner, job Job, timeout time.Duration, maxBytes int) ([]byte, error)
- func Message(stderr string, err error) string
- func ParseComplete(out []byte) ([]string, error)
- func Script(job Job, names []string) string
- func Version(ctx context.Context, r Runner) (string, error)
- type Error
- type Job
- type Nu
- type Problem
- type Runner
- type Shape
Constants ¶
const MinVersion = "0.100.0"
MinVersion is the oldest nu asked about scripts.
Variables ¶
var ErrMissing = errors.New("nu isn't installed or isn't on your PATH: see docs/nushell/notebooks.md")
ErrMissing is what running a cell says when nu isn't installed.
var ErrOld = errors.New("nu is too old to ask about pipelines")
ErrOld is a nu too old to ask, or one whose answers don't read.
var ErrTooLarge = errors.New("the output is too large to keep")
ErrTooLarge is a run that printed more than it may keep.
Functions ¶
func AtLeast ¶
AtLeast reports whether version v is oldest or later; one that doesn't read as major.minor.patch isn't.
func Complete ¶
Complete is what nu would complete at offset, a byte of script, in its order. nu says what goes there, not what it replaces.
func Exec ¶
func Exec(ctx context.Context, r Runner, job Job, timeout time.Duration, maxBytes int) ([]byte, error)
Exec runs job and returns what it printed, NUON, at most maxBytes of it, within timeout.
func Message ¶
Message is the line of nu's standard error that says what went wrong: the one marked ×, or the first, or how the process ended.
func ParseComplete ¶
ParseComplete reads what --ide-complete printed.
Types ¶
type Job ¶
type Job struct {
Command string
// Tables are what the pipeline reads, by variable name, as NUON:
// each becomes the variable of its name.
Tables map[string][]byte
// Config runs nu with the user's config files rather than without.
Config bool
// IDE asks nu about the script rather than running it: the flags
// that ask (--ide-ast, or --ide-complete 14), nu reading the script
// from a file named after them, without config files or the
// standard library (see ide.go).
IDE []string
}
Job is a pipeline to run.
type Nu ¶
type Nu struct {
// Path is the program; "" finds nu on the PATH.
Path string
}
Nu is the real runner: `nu -c` in a process of its own.
type Problem ¶
Problem is what nu's check found wrong with a stretch of a script.
func ParseCheck ¶
ParseCheck reads what --ide-check printed: its diagnostics, each once, leaving out its hints (the types it inferred).
type Runner ¶
Runner runs a job's script, writing what it prints to stdout. A test substitutes a fake for the real nu.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package module holds 012.nu, the nushell module that gives 012 the command `sheet`, so nushell users needn't type `^012` (a bare 012 is a number to nushell).
|
Package module holds 012.nu, the nushell module that gives 012 the command `sheet`, so nushell users needn't type `^012` (a bare 012 is a number to nushell). |