Documentation
¶
Overview ¶
Package editor opens a file in the user's editor: for `strument config edit`, `strument history edit`, and the REPL's /editor.
The resolution order is age-edit's (github.com/dbohdan/age-edit) without its tool-specific variable: VISUAL, then EDITOR, then a default. Same order and the same treatment of the value — an argv, split on shell rules, never a string handed to a shell. The default is where this parts company with age-edit, which says vi everywhere; see fallbackEditors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Argv ¶
Argv is the command that opens path.
$VISUAL and $EDITOR are commands, not program names — `code --wait`, `emacsclient -nw`, `"/opt/My Editor/bin/ed" --wait` — so the value is split the way a shell would split it and executed directly. Not passed to a shell: a path with a space or a dollar sign in it would then be the shell's problem rather than ours, and this is exactly the seam where the difference bites.
Whitespace-only is treated as unset. An editor variable set to " " is somebody's stray quoting, not a request to run a program with no name.
func ArgvFor ¶
func ArgvFor(path string, lookup func(string) string, look func(string) (string, error), goos string) []string
ArgvFor is Argv with the environment, the PATH search and the platform all named rather than taken from the host.
The seam exists for the same reason shlex.SplitWith's does: the branch that is easiest to get wrong is the one CI is least likely to exercise the way a user meets it, so both platforms' answers have to be reachable from a test on either host.
func Run ¶
Run runs argv, the command Argv built, and waits, wiring the editor to the real terminal.
The editor inherits the whole environment, deliberately. The rule in AGENTS.md is about who caused the command: everything the *model* causes runs under the env_allow filter, and everything the *user* typed inherits everything, because they typed it. `strument config edit` is the user reaching for their own editor, which may well read a variable this program has never heard of.
Types ¶
This section is empty.