Skip to main content

Module editor

Module editor 

Source
Expand description

Opening the user’s text editor on a file and waiting for it to close.

The fallback editor list differs per OS (vim/nano/vi against edit/notepad). As in crate::browser, the platform selection is a pure function taking the OS string, the candidate list and argv split are pure, and the actual process run is injected - so nothing here needs a #[cfg] and every branch is reachable under test on a single platform.

What is not here is anything about what the file contains. Building the task template, stripping its comment lines and deciding whether an empty result cancels the run are Leviath policy, not OS behavior, and live in leviath-cli.

Enums§

EditorRunOutcome
Outcome of running one editor candidate, abstracting over the raw ExitStatus. This exists so the “ran but ended with no exit code” case (a signal kill on Unix) is injectable in tests on every platform: on Windows an ExitStatus always carries a code (even via ExitStatusExt::from_raw), so that case cannot be fabricated from a status directly. The injected run seam of launch_via therefore yields this enum rather than an ExitStatus.

Functions§

classify_exit
Classify an editor subprocess’s exit. code == None means it ended without an exit code (a signal kill). A pure function so both arms are unit-testable on every platform, independent of whether a real process can produce a code-less status there.
default_editors_for
The fallback editor candidates for os, tried in order after any $VISUAL/$EDITOR value.
editor_argv
Split one candidate into a program and its arguments, with path appended.
editor_candidates
The full candidate list in priority order: $VISUAL, then $EDITOR, then the platform fallbacks for os.
launch
Launch the user’s editor on path and wait for it to close.
launch_via
Try each candidate in order and return once one runs to completion.