Skip to main content

editor_argv

Function editor_argv 

Source
pub fn editor_argv() -> Result<Argv>
Expand description

Get the editor command from $VISUAL or $EDITOR, parsed into program and args.

Precedence (Unix convention):

  1. $VISUAL (if set and non-empty)
  2. $EDITOR (if set and non-empty)
  3. Falls back to vi

Supports editors with arguments like code --wait or nvim -u NONE.

§Errors

Returns an error if the environment variable value cannot be parsed as shell words (e.g., unbalanced quotes).

§Example

use agentic_tools_utils::cli::editor_argv;

// With no VISUAL/EDITOR set, returns "vi"
std::env::remove_var("VISUAL");
std::env::remove_var("EDITOR");
let argv = editor_argv().unwrap();
assert_eq!(argv.program, "vi");
assert!(argv.args.is_empty());